2011-11-17 86 views
0

我有一份經歷GeoCode的報告中的緯度和經度列表,我使用HTML標記在谷歌地圖上顯示它,但不是所有標記都顯示在地圖上。只有前幾個出現在地圖上。谷歌地圖v3不顯示所有標記,請協助

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<div id="map" style="width: 700px; height: 700px"></div> 
<script type="text/javascript"> 

var latlng = new google.maps.LatLng(40.756, -73.986); 

var options = {center : latlng,zoom : 5,mapTypeId : google.maps.MapTypeId.ROADMAP}; 

// Creating the map 
var map = new google.maps.Map(document.getElementById('map'), options); 

var geocoder = new google.maps.Geocoder(); 
var infowindow; 

function displayLocation(a) {displayMap(a, 0);} 

function displayInfo(a) {displayMap(a, 1);} 

function displayMap(address, displayInfo) 

{geocoder.geocode({'address' : address}, function(results, status) { 


if (status == google.maps.GeocoderStatus.OK) { 


map.setCenter(results[0].geometry.location); 


var marker = new google.maps.Marker({ 


map : map, 



position : results[0].geometry.location}); 



if (!infowindow) { infowindow = new google.maps.InfoWindow();} 



infowindow.setContent(address); 


if (displayInfo == 1) {infowindow.open(map, marker);} 



} else {// alert("Incorect adress: " +status+address);} 
    }); 
} 
</script> 

回答

0

從你的代碼,我認爲有以下線在某些時候

if (status == google.maps.GeocoderStatus.OK) { 

你有一個else statment返回false,但這不是正確關閉。註釋// alert也註釋掉}

所以,你可能需要改變這

else { 
    // alert("Incorect adress: " +status+address); 
} 

,而不是

else {// alert("Incorect adress: " +status+address);}