0

我正在Cordova开发基于Google地图的应用程序,并希望根据顶部搜索栏中地名匹配结果触发信息窗口(我有存储在Web SQL数据库中的所有位置名称,纬度,经度,自定义标记和信息窗口内容)。只是想知道这样做的最佳方式,不会重复点击标记触发的信息窗口弹出窗口。信息窗口弹出触发搜索

也有同一名称的多个位置(不同分支具有相同的公司名称),我想要缩小地图并同时显示所有匹配的信息窗口弹出窗口(如果搜索到公司名称在搜索栏中。有谁知道这是否可能?

回答

0

不太明白你的问题,

可以使信息窗口打开,只要你愿意

信息窗口搜索打开后:

//put in your callback of matching results of the place name in a search bar 
var infowindow = new google.maps.InfoWindow(); 
infowindow.setContent(yourContent) 
infowindows.push(map,mark) 

对于第二个问题

你可以看到谷歌API文档,使用谷歌LatlngBounds,

//set google map bounds obj 
var bounds = new google.maps.LatLngBounds() 

//for every place you want to display on map 
if (place.geometry.viewport) 
    bounds.union(place.geometry.viewport) 
else 
    bounds.extend(place.geometry.location) 
//finally 
map.fitBounds(bounds) 
相关问题