views:

76

answers:

1

I have been looking over this code for the past hour, I cant see why html pop up will not show, I'm probably missing something simple as no errors are reported.

var map;
var markers = new Array();
var geocoder;
function initialize() {
 if (GBrowserIsCompatible()) {
  map = new GMap2(document.getElementById("map"));
  map.setCenter(new GLatLng(<?php echo $map_center; ?>), 17);
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
   geocoder = new GClientGeocoder(); 

 }
}

function createMarker(point,number) { 

 var marker = new GMarker(point);
 marker.value = number;

 GEvent.addListener(marker, "click", function() {

  map.openInfoWindowHtml(point, createInfoText());

 });  


 return marker;
}

function createInfoText() {
 var html = '<p>hello world</p>';
 return html;
}

$(document).ready(function () {
 initialize();
 var point = new GLatLng("51.2357, -0.5726");   
 map.addOverlay(createMarker(point,1));

});

Thanks in advance all

+3  A: 

Couple lines look a little funky.

This one:

var point = new GLatLng("51.2357, -0.5726");

should be:

var point = new GLatLng(51.2357, -0.5726);

And for this one:

map.setCenter(new GLatLng(<?php echo $map_center; ?>), 17);

you should ensure $map_center is a , separated string of two floats.

Roatin Marth
I really need to stop being lazy and writing out the code lolThanksvar point = new GLatLng(51.2357, -0.5726);Solved the problem
blakey87