简体   繁体   English

Google Map API问题...!

[英]Problem in Google Map API…!

Hi there i'm currently working with google map api 嗨,我目前正在使用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 我从Google api文档学习时了解了api函数,因此编写了以下代码

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(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 .... createmarker是我的功能,可以正常工作,但是问题是这个带有地址的随机标记来自地址数组,有时是10、12、14、14等。

I just want to plot all the address exists in my address array and on the google maps too.. 我只想绘制所有存在于我的地址数组中以及Google地图上的地址。

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. createMarker函数应如下所示。 Please see my example here , where you can add multiple markers on the map. 在此处查看我的示例,您可以其中添加多个标记。 Complete javascript can be found here . 完整的javascript可以在这里找到。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM