I found a bit of Google Maps Javascript at JSFiddle: http://fiddle.jshell.net/bTujZ/885/
I'm trying to get it to run by enclosing the script between script tags and then calling it in the body like so:
<body onload="initialize()">
<div id="map_canvas" style="width:400px; height:400px"></div>
</body>
When I attempt to load the page it is blank.
My full code follows:
<html>
<head>
<script language="javascript">
var points = [
['name1', 59.9362384705039, 30.19232525792222, 12, 'www.google.com'],
['name2', 59.941412822085645, 30.263564729357767, 11, 'www.amazon.com'],
['name3', 59.939177197629455, 30.273554411974955, 10, 'www.stackoverflow.com']
];
function setMarkers(map, locations) {
var shape = {
coord: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};
for (var i = 0; i < locations.length; i++) {
var flag = new google.maps.MarkerImage(
'http://googlemaps.googlermania.com/google_maps_api_v3/en/Google_Maps_Marker.png',
new google.maps.Size(37, 34),
new google.maps.Point(0,0),
new google.maps.Point(0, 19)
);
var place = locations[i];
var myLatLng = new google.maps.LatLng(place[1], place[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: flag,
shape: shape,
title: place[0],
zIndex: place[3],
url: place[4]
});
google.maps.event.addListener(marker, 'click', function() {
alert('go to ' + this.url);
//window.location.href = this.url;
});
}
}
function initialize() {
var myOptions = {
center: new google.maps.LatLng(59.91823239768787, 30.243222856188822),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, points);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:400px; height:400px"></div>
</body>
</html>
I'm certain I'm making a boneheaded error, as I'm new to Javascript.