I am making a google map as part of a university project. here
and am having a few problems. Basicly for some reason my markers are not appearing as i don't think my array is being read.
Using the firebug plugin i am getting the following error message: markers is not defined
init()map_functions.js (line 24)
for(id in markers) { .
I don't really get how to solve this problem.
var centerLatitude = 51.523647; //longittude and latitude coordinates and zoom geocodes
var centerLongitude = -0.146470;
var startZoom = 14;
var description = 'London';
function addMarker(latitude, longitude, description) {
var marker = new GMarker(new GLatLng(latitude, longitude));
GEvent.addListener(marker, 'click',
function() {
marker.openInfoWindowHtml(description);
}
);
map.addOverlay(marker);
}
function init() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
for(id in markers) {
addMarker(markers[id].latitude, markers[id].longitude, markers[id].name, markers[id].pcode);
}
}
}
window.onload = init;
window.onunload = GUnload;
my data looks like this.
var markers = [
{
'latitude': 51.51383,
'longitude': -00.15246,
'name': 'Balderton street',
'pcode': 'W1'
}
];
any help would be greatly appreciated as the project is due in on Friday!
dave