Forum Moderators: open
All I want to do is to be able to add markers with info windows with predefined location and window text. I am attempting to modify the example google gives (which uses a for statement with 10 random markers) and so far I am only able to display 1 static location, as when I enter the second one it doesn't show up.
The code for google's example is as follows (apologies for the length):
*please make note of the need for an API Key, although if you are developing with google maps I'm sure you already know
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps API Example - markerinfowindow</title>
<style type="text/css">
v\:* {
behavior:url(#default#VML);
}
</style>
<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAEfCuQGsNiSWxRgf_vfNWaRQjskl1-YgiA_BGX2yRrf7htVrbmBTEB0IH-F489GrwP8-dHLib7cKKIQ" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[function onLoad() {
// Display Info Windows Above Markers
//
// In this example, we show a custom info window above each marker by
// listening to the click event for each marker. We take advantage of function
// closures to customize the info window content for each marker.
// Center the map on Palo Alto
var map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(-122.141944, 37.441944), 4);
// Creates a marker whose info window displays the given number
function createMarker(point, number) {
var marker = new GMarker(point);
// Show this marker's index in the info window when it is clicked
var html = "Marker #<b>" + number + "</b>";
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
// Add 10 random markers in the map viewport
var bounds = map.getBoundsLatLng();
var width = bounds.maxX - bounds.minX;
var height = bounds.maxY - bounds.minY;
for (var i = 0; i < 10; i++) {
var point = new GPoint(bounds.minX + width * Math.random(),
bounds.minY + height * Math.random());
var marker = createMarker(point, i + 1);
map.addOverlay(marker);
}
}//]]>
</script></head>
<body onload="onLoad()">
<div id="map" style="width: 500px; height: 300px"></div>
<div id="message"></div>
</body>
</html>
Can someone please show me how to break apart that for statement and add 2 locations with hard-coded location and window text.
I would GREATLY appreciate any help, as I am very frustrated that I cannot accomplish what should be such a simple thing
Thank you very much,
Mike
[bluweb.com...]
enjoy
-Mike
[edited by: jatar_k at 9:06 pm (utc) on Aug. 8, 2005]