我尝试在搜索后打开信息窗口并平移到谷歌地图上的位置。有人能帮我吗?谢谢你。
var availableTags = [];
for (i=0;i<mapLocationsJSON.length;i++){
availableTags[i]=mapLocationsJSON[i].title;
}
//This is the autocomplete text field
$(function() {
$( "#search" ).autocomplete({
source: availableTags
});
});
//Insert the function here for what you want it to do when you search
function myFunc(searchTerm){
var validSearch=false;
var markerNumber;
//Check to see if the term they searched for matches any of the locations in the map data
for (i=0;i<mapLocationsJSON.length;i++){
if(searchTerm==mapLocationsJSON[i].title){
validSearch=true;
markerNumber=i;
break;
}
}
if(validSearch){
//Pan to the position and zoom in.
map.panTo(markers[markerNumber].getPosition());
map.setZoom(7);
//I'm not sure how to open the info window.... ?
//infowindow.open(map,markers[markerNumber]);
}else{
//if the data doesn't match a term, ask them to search again.
alert("Please try again")
};
}
搜索完位置后我应该怎么做才能打开信息窗口