林有一些問題顯示根據變焦級別2層不同的標誌物。例如,如果縮放級別小於10,則顯示圖標a,如果縮放級別大於10,則顯示圖標2.我一直在查看標記管理器,但稍微失去了一些方向。這裏是我的代碼:谷歌地圖標記管理器
var url = "json.api";
function initialize() {
var myLatlng = new google.maps.LatLng(0, 0);
var myOptions = {
maxZoom: 16,
zoomControl: true,
disableDefaultUI: true,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
downloadUrl(url, function(data) {
var j = eval('(' + response + ')');
var jlength = j.data.hotels.length;
var bounds = new google.maps.LatLngBounds();
for(i=0; i < jlength; i++) {
var x = parseFloat(j.data.hotels[i].lat);
var y = parseFloat(j.data.hotels[i].lon);
var z = new google.maps.LatLng(x,y);
var title = j.data.hotels[i].title;
var hotel_id = j.data.hotels[i].id;
var address = j.data.hotels[i].address;
var star = j.data.hotels[i].star;
var thumbnail = j.data.hotels[i].thumbnail;
var contentstring = 'some html';
var marker = createMarker();
var infowindow = new google.maps.InfoWindow({
content: contentstring
});
bounds.extend(z);
map.fitBounds(bounds);
//NOT SURE IF THESE ARE NEEDED
// zoomChangeBoundsListener = google.maps.event.addListener(map, 'bounds_changed', function(event) {
// google.maps.event.removeListener(zoomChangeBoundsListener);
// });
// google.maps.event.addListener(map, 'zoom_changed', function() {
// });
};
if (map.getZoom() == 21) {map.setZoom(16);}
if (map.getZoom() < 12) {map.setZoom(map.getZoom()+1);}
//alert(map.getZoom())
function createMarker(){
var marker = new google.maps.Marker({
position: z,
map: map,
title: title,
html: contentstring,
icon: 'icona.png'
});
google.maps.event.addListener(marker,'click',function(){
infowindow.setContent(this.html);
infowindow.open(map,marker);
});
};
});
};
,你看,我有一個JSON文件,我遍歷得到lat和LNG(等位),然後創造出有信息顯示在我的JSON文件的一切標誌窗口等....我可以不只是創建第二個標記功能,即createMarker2和一些如何調用,如果變焦超過10?...任何幫助,將不勝感激。我在網上看了一些例子,但感到困惑。提前致謝。
謝謝,生病讓我們去讓你知道 – Hatzi