I set up a map with one marker and InfoWindow based on an example in
the Google API tutorial. No problem. I set up a second marker. No
problem. When I try to set up a different InfoWindow
for the second marker they both show the second one. I'm sure it's a
simple fix but since I'm muddling through this....
Here's the js:
// JavaScript Document
function initialize() {
var myLatlng = new google.maps.LatLng(37.8736111,-122.4555556);
var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new
google.maps.Map(document.getElementById("map_canvas"),
myOptions);
// Marker1
var marker1 = new google.maps.LatLng(37.8736111,-122.4555556);
var contentString1 = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h2 id="firstHeading" class="firstHeading">Blackie’s
Pasture</h1>'+
'<div id="bodyContent">'+
'<p><b>Historical Marker No. 1</b></p> '+
'<p>The pasture where Blackie lived </p> '+
'<a href="images/harvey.jpg" alt="Harvey" width="185" height="209"
target="_blank">' +
'<img src="images/harvey.jpg" alt="Harvey" width="93"
height="104"
/></a>' +
'<img src="images/marker-test.jpg" alt="Marker placque"
width="93"
height="104" /></a><br />' +
'<em>Click on a photo to enlarge it</em>' +
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString1
});
var marker1 = new google.maps.Marker({
position: marker1,
map: map,
title: "Blackie's Pasture"
});
google.maps.event.addListener(marker1, 'click', function() {
infowindow.open(map,marker1);
});
// Marker2
var marker2 = new
google.maps.LatLng(37.8837959515249951,-122.46597290039062);
var contentString2 = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h2 id="firstHeading" class="firstHeading">Marker Number 2</
h1>'+
'<div id="bodyContent">'+
'<p><b>The second marker</b></p> '+
'<p>Just another place </p> '+
'<a href="images/harvey.jpg" alt="Harvey" width="185" height="209"
target="_blank">' +
'<img src="images/harvey.jpg" alt="Harvey" width="93"
height="104"
/></a>' +
'<img src="images/marker-test.jpg" alt="Marker placque"
width="93"
height="104" /></a><br />' +
'<em>Click on a photo to enlarge it</em>' +
'</div>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString2
});
var marker2 = new google.maps.Marker({
position: marker2,
map: map,
title: "Marker Number 2"
});
google.maps.event.addListener(marker2, 'click', function() {
infowindow.open(map,marker2);
});
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.