Javascript google maps v3未显示所有标记,请协助
我在一份报告中有一个纬度和经度的列表,通过地理编码,我使用HTML标签在谷歌地图上显示它,但不是所有的标记都显示在地图上。只有前几个出现在地图上Javascript google maps v3未显示所有标记,请协助,javascript,google-maps,google-maps-markers,Javascript,Google Maps,Google Maps Markers,我在一份报告中有一个纬度和经度的列表,通过地理编码,我使用HTML标签在谷歌地图上显示它,但不是所有的标记都显示在地图上。只有前几个出现在地图上 <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" 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>
var latlng=新的google.maps.latlng(40.756,-73.986);
var options={center:latlng,zoom:5,mapTypeId:google.maps.mapTypeId.ROADMAP};
//创建地图
var map=new google.maps.map(document.getElementById('map'),options);
var geocoder=new google.maps.geocoder();
var信息窗口;
函数displayLocation(a){displayMap(a,0);}
函数displayInfo(a){displayMap(a,1);}
功能显示映射(地址、显示信息)
{geocoder.geocode({'address':address},函数(结果,状态){
if(status==google.maps.GeocoderStatus.OK){
map.setCenter(结果[0].geometry.location);
var marker=新的google.maps.marker({
地图:地图,
位置:结果[0].geometry.location});
如果(!infowindow){infowindow=new google.maps.infowindow();}
infowindow.setContent(地址);
如果(displayInfo==1){infowindow.open(map,marker);}
}else{//alert(“不正确的地址:+状态+地址);}
});
}
从您的代码中,我认为以下行在某个点返回false
if (status == google.maps.GeocoderStatus.OK) {
您确实有一个else
station,但它没有正确关闭。注释//alert
也注释掉了}
所以你可能需要把这个改成
else {
// alert("Incorect adress: " +status+address);
}
而不是
else {// alert("Incorect adress: " +status+address);}