[英]How to add/filter markers on gmap v3
我想添加一個Google地圖,例如http://puu.sh/6VgI0.png ,其中我有10個位置,每個位置都有1.title,2.address,3.phone號碼和4.category(診所或醫院)我想按上述屏幕截圖中的類別過濾位置。 任何幫助,將不勝感激。
步驟1:在使用自定義標記圖標獲取各自的位置點后,在地圖中添加標記。 像下面這樣
var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: iconBase + 'schools_maps.png'
});
步驟2:接下來,您應該對其他圖標組重復相同的操作。
步驟3:根據復選框選擇(為哪個組可見或不可見)為兩者編寫一個函數
步驟4:在“標記”中,您可以附加事件,同時單擊以顯示包含所有信息的彈出窗口。
google.maps.event.addListener(marker, 'click', function() {
// Show popup screen here based on marker parameter.
});
有關完整的示例,您可以參考此文檔https://developers.google.com/maps/documentation/javascript/events
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.