Google Maps v3 не отображает все маркеры, пожалуйста, помогите - PullRequest
0 голосов
/ 17 ноября 2011

У меня есть список широт и долгот в отчете, который проходит через GeoCode, и я использую HTML-тег для отображения его на карте Google, но не все маркеры отображаются на карте. на карте появляются только первые несколько.

<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>

1 Ответ

0 голосов
/ 17 ноября 2011

из вашего кода Я думаю, что следующая строка возвращает false в какой-то момент

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

у вас есть else оценка, но она закрыта неправильно.Комментарий // alert также комментирует }

Так что вам, вероятно, нужно изменить это значение на

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

вместо

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