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)