开发者

Problem in Google Map API...!

Hi there i'm currently working with google map api

for plotting multiple address with marker

i have written the following code as i understand the api function while study from google api documentation

for(var i=0; i<address.length; i++){
geocoder.getLocations(address[i],function(response){    
            if(response){
                place = response.Placemark[0];
                  point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
                map.setCenter(point, 12);
                map.addOverlay(createmarker开发者_StackOverflow社区(point));
            }
});
}

createmarker is my function which works properly but the problem is this this place random markers with the address comes from address array sometimes 10, 12, 14, 14, and so on ....

I just want to plot all the address exists in my address array and on the google maps too..

so it must be fixed number of markers onto the map...!

So is there anyone who can help me for this issue..!

Thanks is advanced


The createMarker function should look like this. Please see my example here, where you can add multiple markers on the map. Complete javascript can be found here.

function createMarker(latlng) {
   var contentString = html;
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        zIndex: Math.round(latlng.lat()*-100000)<<5
    });

    google.maps.event.addListener(marker, 'click', function() {
        infowindow.setContent(contentString); 
        infowindow.open(map,marker);
    });
    marker.MyZoom = zoom; 
    return marker; 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜