how can i loop through an array and still use the overlayview class?
because the code below isn't working ..it only works when i manually
assign a lat/lng to the overlayview class.

$(document).ready(function()
{
var overlay;

var myLatlng = new google.maps.LatLng(51.501743,-0.140461);

var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);

OverlayTest.prototype = new google.maps.OverlayView();

var items = [
  [51.501743,-0.140461],
  [51.506209,-0.146796],
];

for(var i = 0; i < items.length; i++)//loop through array
{
var latlng = new google.maps.LatLng(items[i][0], items[i][1]);

var bounds = new google.maps.LatLngBounds(latlng);

overlay = new OverlayTest(map, bounds);

var element_id = 'map_' + i;

function OverlayTest(map, bounds)
{
this.bounds_ = bounds;

this.map_ = map;

this.div_ = null;

this.setMap(map);
}

OverlayTest.prototype.onAdd = function()
{
var div = '';

this.div_ = div;

var panes = this.getPanes();

panes.mapPane.innerHTML = div;
}

OverlayTest.prototype.draw = function()
{
var overlayProjection = this.getProjection();

var sw =
overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest());
var ne =
overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast());

var div = document.getElementById(element_id);

div.style.left = sw.x + 'px';
div.style.top = ne.y + 'px';
}
}
});

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to google-maps-js-api...@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to