views:

23

answers:

1

 

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
+1  A: 

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]);
}
Daniel Vassallo
simple is better thanks
Harry