Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Roseo
Jun 1, 2000
Forum Veteran
Anyone have idea why this won't generate markers in an embedded Google Map under Chrome but works on every other browser I've tested it under? I know it can stand to be refactored, but I can't figure out why the gently caress this basic code doesn't generate my markers.


code:
var info = [ 'html', 'html', 'html' ];
var locs = [ '40', '-50', '42', '-51', '44', -56' ]; 

function drawmap() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map_canvas"));

    var id = 1;
    while (locs.length > 0) { // While the array is populated...
      var point = new GLatLng(locs.shift(), locs.shift()); //locs is array of alternating lats and longs, shift it twice to get the coords back.
      map.addOverlay(createMarker(point, id));
      id++;
    }
  }
}

function createMarker(point, id) {
  var towerIcon = new GIcon(baseIcon);
	
  var marker = new GMarker(point);
  marker.value = id;
  GEvent.addListener(marker, "click", function() {
    var html = info[id-1];
    map.openInfoWindowHtml(point, html);
  });
  return marker;
}

Roseo fucked around with this message at 01:57 on Apr 8, 2009

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply