2
我在加載標記的代碼中有此方法,但它不起作用。標記不顯示
function loadMarkers() {
if (locations.length > 0) {
var local = locations.split(';');
for (var i = 0; i < local.length; i++) {
var center = local[i].split(',');
var iconoMarca = imagePath;
var position = new google.maps.LatLng(center[0],
center[1]);
var marker = new google.maps.Marker({
position: position,
image: iconoMarca,
optimized: false,
map: map,
draggable: true
});
}
}
}
我知道的方法,它被稱爲是因爲我做鉻調試,但不能看到問題,對我來說它的代碼的罰款。這是事件的監聽
google.maps.event.addListenerOnce(map, 'idle', loadMarkers);
THI是初始化地圖
function initialize() {
$(".btnSaveMarkers").click(saveMarkers);
$(".btnResetMap").click(resetMap);
$(".btnCleanMarkers").click(removeAllMarkers);
//build the map
$.ajax({
async: false,
type: "POST",
url: "SetMarkers.aspx/findMapParameters",
data: "{idMapa: '" + idMap + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: response
});
var mapDiv = document.getElementById('map-canvas');
map = new google.maps.Map(mapDiv, {
center: new google.maps.LatLng(lat, lng),
zoom: zoom,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
disableDoubleClickZoom: true
});
google.maps.event.addListenerOnce(map, 'idle', loadMarkers);
google.maps.event.addListener(map, 'dblclick', addMarkers);
}