Google Maps: Multimarker not working

Posted by HyperDevil on Stack Overflow See other posts from Stack Overflow or by HyperDevil
Published on 2011-02-12T15:01:12Z Indexed on 2011/02/12 15:25 UTC
Read the original article Hit count: 201

Filed under:
|
|

Hi, I want to plot several markers on my map. Found some code on the internet, for that user it worked. The array is generated by PHP, example: var ships = [['61','10.2']['60.5','10.1']];

My Javascript:
var map;

function load(ships) {
initialize();
createShips(ships);
}

function initialize() {

//build the map
var myLatlng = new google.maps.LatLng(63.65,10.65);
var myOptions = {
zoom: 9,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

function createShips(ships) {
for (var i = 0; i < ships.length; i++) {
new google.maps.Marker({
position: new google.maps.LatLng(ships[i][0], ships[i][1]),
map: map,
title: ships[i][0]
});
}
}

My html function to start the map is: body onload="load()"

The map seems to appear, but no markers :(

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about google-maps