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(poi开发者_开发知识库nt,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
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.
精彩评论