我在报告中列出了纬度和经度列表,这些列表通过GeoCode,我使用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">
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 :(得分:0)
我认为以下行在某些时候返回false
if (status == google.maps.GeocoderStatus.OK) {
您确实有else
声明,但未正确关闭。评论// alert
也会评论}
所以你可能需要将其更改为
else {
// alert("Incorect adress: " +status+address);
}
而不是
else {// alert("Incorect adress: " +status+address);}