google maps api v3 - loop through overlays - overlayview methods
Posted
by user317005
on Stack Overflow
See other posts from Stack Overflow
or by user317005
Published on 2010-05-24T07:53:20Z
Indexed on
2010/05/24
8:01 UTC
Read the original article
Hit count: 665
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]
}
}
© Stack Overflow or respective owner