我正在Cordova开发基于Google地图的应用,并希望根据顶部搜索栏中地名的匹配结果触发信息窗口(我有所有的位置名称,纬度,经度,自定义标记和存储在Web SQL数据库中的信息窗口内容。只是想知道这样做的最好方法是不会复制通过单击标记触发的信息窗口弹出窗口。
还有多个位置具有相同的名称(具有相同公司名称的不同分支),我想缩小地图并在搜索公司名称的同时显示所有匹配的信息窗口弹出窗口搜索栏。有谁知道这是否可能?
答案 0 :(得分:0)
不太明白你的问题,
你可以随时打开信息窗口
Infowindow在搜索后打开:
//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文件,使用google 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)