2011-11-17 66 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);}