我想要改變標記的地圖。具體來說,我有三個不同的標記集合,所以我使用未定義的地圖構建它們,然後在集合之間切換時嘗試設置它們的地圖屬性。它不工作 - 只有在構造函數中傳遞地圖時纔會顯示標記。谷歌地圖v3改變標記的地圖
//Build a new marker with no map
var marker = new google.maps.Marker({
position: pos,
title: el.name + " #" + el.location_id,
map: null
});
markers[el.location_id] = marker;
//Later, when displaying
$.each(markers, function(i, marker){
marker.map = map;
});
//Marker doesn't show up.
此外,當我創建一個標記,然後取出它的地圖,它仍顯示:
var marker = new google.maps.Marker({
position: pos,
title: el.name + " #" + el.location_id,
map: map
});
marker.map = null;
//Marker is still on the map...