I try to open the info window after searching and pan the status on Google Maps. Can someone help me? Thank you.
var availableTags = []; For (i = 0; iLt; mapLocationsJSON.length; i ++) {Available Tugs [i] = Map Location JSON [i] .title; } // This autocomplete text field is $ (function () {$ ("#search"). Autocomplete ({source: availableTags});}); // function myFunc (searchTerm) {var validSearch = false; Enter the function here for what you want to do when searching; Var marker number; // To see if the word has been searched, whether or not matte data matches any of the matte data for (i = 0; i & lt; JSON.length; i ++ for the map); {If searchTerm == mapLocationsJSON [i] .title) {validSearch = true; MarkerNumber = I; break; }} If (valid search) {// status pan and zoom in map. Panto (marker [marker number] .getPosition ()); Map.setZoom (7); // I'm sure how to open the info window ....? //infowindow.open(map-markers[markerNumber]); } Else {// If the data does not match any word, ask them to search again. Warning ("Please try again")}; } After searching the location, what should I do to open the info window
Assume that you already have a click listener on the marker (you do not include your code which defines the marker), the simplest way:
if (valid Search) {// position pan and zoom in Map.panTo (Marker [Marker Number] .getPosition ()); Map.setZoom (7); // Click marker google.maps.event.trigger (marker [marker number], 'click'); } Else {// If the data does not match any word, ask them to search again. Warning ("Please try again")}
No comments:
Post a Comment