地理编码器-多个市场不显示标题

Geocoder - multiple markes won't show title

本文关键字:显示 标题 个市 编码器      更新时间:2023-09-26

我有一个问题,地理编码器不显示每个标记的标题。下面是代码:

var map;
var marker = [];
function gmap_initialize() {        
    var ikonica = templateDir+'/images/gmap/gmap_pointer_and_shadow.png';
    var map_canvas = document.getElementById('gmap');   
    var my_latlan = new google.maps.LatLng(45.55496, 18.69551);
    var map_options = {
        center: my_latlan,
        zoom: 13,     
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(gmap, map_options);
    var geocoder = new google.maps.Geocoder();
    //js_adrese below is actually an array that contains addresses  
    for (i=0; i<js_adrese.length; i++)
    {           
        geocoder.geocode( {'address': js_adrese[i]}, function(results, status) {        
        if (status == google.maps.GeocoderStatus.OK) 
        {               
            var x = results[0].geometry.location.lat();
            var y = results[0].geometry.location.lng();             
            marker[i] = new google.maps.Marker({                    
               position: results[0].geometry.location,
               map: map,                   
               icon: ikonica,
               title: js_adrese[i] // undefined in console
            });             
        } 
        else 
        {
            alert("Geocode failed. Reason: " + status);
        }
    });     
}
};

当我设法显示标题时,它只显示js_adrese[I]的最后一个值,所以每个标记都有相同的标题。

重要:我对js和google api完全是一个新手,所以,如果你能把技术谈话降低到我白痴的水平,用蹩脚的术语指出来,问题是什么,如何解决它?请

谷歌地图地理代码服务(个人)只允许每秒10个请求或接近这个数字。试着减少你的请求,说2或3个地址,如果这是正确的,那么你必须离线地理编码和创建您的标记从生成的晚和长。