Reputation: 39
I have this HTML file(below) Which is almost identical to the one found here. https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple
My issue I'm am having is I see nothing wrong with any of the script portion or HTML, then again I'm writing this for a non-profit as a volunteer and I don't normally do this HTML or javascript. This file is generated by a perl script so please be easy on me.
Let me know what i did wrong please!
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>e-NABLE Event Map</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
function initialize() {
var myHome = new google.maps.Latlng(-77.675106,43.090076);
var mapOptions = {
zoom: 4,
center: myHome
};
var map = new google.maps.Map(document.getElementByID('map-canvas'), mapOptions);
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+
'<div id="bodyContent">'+
'<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
'sandstone rock formation in the southern part of the '+
'Northern Territory, central Australia. It lies 335 km (208 mi) '+
'south west of the nearest large town, Alice Springs; 450 km '+
'(280 mi) by road. Kata Tjuta and Uluru are the two major '+
'features of the Uluru - Kata Tjuta National Park. Uluru is '+
'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
'Aboriginal people of the area. It has many springs, waterholes, '+
'rock caves and ancient paintings. Uluru is listed as a World '+
'Heritage Site.</p>'+
'<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
'http://en.wikipedia.org/w/index.php?title=Uluru</a> '+
'(last visited June 22, 2009).</p>'+
'</div>'+
'</div>';
var myLatlng0 = new google.maps.LatLng(-77.675106,43.090076);
var infowindow0 = new google.maps.InfoWindow({
content: contentString
});
var marker0 = new google.maps.Marker({
position: myLatlng0,
map: map,
title: 'e-NABLE Home Base'
});
google.maps.event.addListener(marker0, 'click', function() {
infowindow.open(map,marker0);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
Upvotes: 1
Views: 47
Reputation: 10627
JavaScript is case-sensitive. new google.maps.Latlng(-77.675106,43.090076)
is supposed to be new google.maps.LatLng(-77.675106,43.090076)
anddocument.getElementByID('map-canvas')
should be document.getElementById('map-canvas')
. Personally, I don't like to type google.maps
or use document.getElementById()
, so I do this:
var doc = document, bod = document.body, gm = google.maps;
function E(e){
return doc.getElementById(e);
}
var myHome = new gm.LatLng(-77.675106,43.090076);
var canvas = E('map-canvas'); // same as document.getElementById('map-canvas');
Upvotes: 1