google maps api v3 - loop through overlays - overlayview methods
- by user317005
what's wrong with the code below? when i execute it, the map doesn't even show up.
but when i put the overlayview methods outside the for-loop and manually assign a lat/lng then it magically works?!
but does anyone know how i can loop through an array of lats/lngs (=items) using the overlayview methods?
i hope this makes sense, just don't know how else to explain it. and unfortunately, i run my code on my localhost
var overlay;
OverlayTest.prototype = new google.maps.OverlayView();
[taken out: options]
var map = new google.maps.Map(document.getElementById('map_canvas'), options);
var items = [
['lat','lng'],['lat','lng']
];
for (var i = 0; i < items.length; i++)
{
var latlng = new google.maps.LatLng(items[i][0], items[i][1]);
var bounds = new google.maps.LatLngBounds(latlng);
overlay = new OverlayTest(map, bounds);
function OverlayTest(map, bounds)
{
[taken out: not important]
this.setMap(map);
}
OverlayTest.prototype.onAdd = function()
{
[taken out: not important]
}
OverlayTest.prototype.draw = function()
{
[taken out: not important]
}
}