2011-06-09 174 views
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); 
} 

回答

2

英里的問題很簡單,我收到中央錯功能,只有那些我需要做的事情是通過lng center[1]通過center[0]開關緯度並且還添加與具有屬性的標記相關聯的縮放zoom