开发者

Google Maps Api v2 error

开发者 https://www.devze.com 2023-01-02 22:21 出处:网络
  var mymarkers= []; //array function createMarker(point,html,ref){ var marker = new GMarker(point);

 

var mymarkers= []; //array

function createMarker(point,html,ref){  
    var marker = new GMarker(point);
    mymarkers[ref] = marker;
    GEvent.addListener(newmarker,'click',function(){newmarker.openInfoWindowHtml(html);开发者_运维问答});
    map.addOverlay(newmarker);
}

This function works well, it adds a marker to the map no problem, but when trying to use mymarkers[] array of markers they have not been stored?

Is there a validator to check the GMarker is nice and clean?

google maps main.js throws a wobbly:

Uncaught TypeError: Cannot read property '__e_' of undefined


It looks like you need to use mymarkers[ref] instead of newmarker (which is undefined). Actually, the function could be simplified further as follows:

var mymarkers = [];

function createMarker (point, html, ref) {  
    mymarkers[ref] = new GMarker(point);;
    GEvent.addListener(mymarkers[ref], 'click', function () {
        mymarkers[ref].openInfoWindowHtml(html);
    });
    map.addOverlay(mymarkers[ref]);
}
0

精彩评论

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