From GamingWiki
Line 15: | Line 15: | ||
// Initialization | // Initialization | ||
+ | |||
+ | var geocoder; | ||
+ | var map; | ||
function initialize() { | function initialize() { | ||
Line 23: | Line 26: | ||
mapTypeId: google.maps.MapTypeId.ROADMAP | mapTypeId: google.maps.MapTypeId.ROADMAP | ||
} | } | ||
− | + | map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
− | + | geocoder = new GClientGeocoder(); | |
− | + | getMarkerList(); | |
} | } | ||
− | + | // Initialize on page load | |
− | + | google.maps.event.addDomListener(window, 'load', initialize); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
// Helper function | // Helper function | ||
− | function | + | function addMarkerByLatLng(lat, lng, title, description) { |
var latlng = new google.maps.LatLng(lat, lng); | var latlng = new google.maps.LatLng(lat, lng); | ||
− | var marker = new google.maps.Marker({position:latlng, map: map, title: | + | var marker = new google.maps.Marker({position:latlng, map: map, title:title}); |
var infowindow = new google.maps.InfoWindow({ | var infowindow = new google.maps.InfoWindow({ | ||
− | content: "<div class=\"mapmarker\">\n" + | + | content: "<div class=\"mapmarker\">\n" + description + "\n</div>" |
}); | }); | ||
− | google.maps.event.addListener(marker, "click", function() { | + | google.maps.event.addListener(marker, "click", function() { infowindow.open(map,marker); }); |
− | |||
− | |||
return marker; | return marker; | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Add markers by address | ||
+ | */ | ||
+ | function addMarkerByAddress(address, title, description) { | ||
+ | if (geocoder) { | ||
+ | geocoder.getLatLng(address, function(latlng) { | ||
+ | if (!latlng) { | ||
+ | alert(address + " not found"); | ||
+ | } else { | ||
+ | var marker = new google.maps.Marker({position:latlng, map:map, title:name}); | ||
+ | google.maps.event.addListener(marker, "click", function() { infowindow.open(map,marker); }); | ||
+ | } | ||
+ | }); | ||
+ | } | ||
} | } | ||
Line 55: | Line 63: | ||
* Set up the various locations in Ghost Town, to be placed on the map. | * Set up the various locations in Ghost Town, to be placed on the map. | ||
*/ | */ | ||
− | function getMarkerList( | + | function getMarkerList() { |
− | |||
− | |||
// The Purple Door | // The Purple Door | ||
− | + | addMarkerByLatLng(44.234807,-76.490271, | |
"The Purple Door", | "The Purple Door", | ||
"<p><b>The Purple Door Books & Gifts</b></p> " + | "<p><b>The Purple Door Books & Gifts</b></p> " + | ||
Line 65: | Line 71: | ||
"Threats of foreclosure have been hounding the Purple Door, and causing "+ | "Threats of foreclosure have been hounding the Purple Door, and causing "+ | ||
"its proprietor, Madame Esmerelda, to scramble to keep it open. " | "its proprietor, Madame Esmerelda, to scramble to keep it open. " | ||
− | + | ); | |
// Woolen mill | // Woolen mill | ||
− | + | addMarkerByLatLng(44.242524,-76.482053, | |
"The Woolen Mill", | "The Woolen Mill", | ||
"<p><b>The Woolen Mill</b></p> " + | "<p><b>The Woolen Mill</b></p> " + | ||
Line 74: | Line 80: | ||
"The Woolen Mill is an office building in downtown Kingston that houses, " + | "The Woolen Mill is an office building in downtown Kingston that houses, " + | ||
"among other companies and agencies, a StarTek call centre.</p> " | "among other companies and agencies, a StarTek call centre.</p> " | ||
− | + | ); | |
// Queen's Library | // Queen's Library | ||
− | + | addMarkerByLatLng(44.228188,-76.496108, | |
"Joseph S. Stauffer Library", | "Joseph S. Stauffer Library", | ||
"<p><b>Joseph S. Stauffer Library</b></p> " + | "<p><b>Joseph S. Stauffer Library</b></p> " + | ||
Line 84: | Line 90: | ||
"Any book mentioning the occult or the supernatural has been lost, stolen " + | "Any book mentioning the occult or the supernatural has been lost, stolen " + | ||
"or defaced.</p> " | "or defaced.</p> " | ||
− | + | ); | |
− | + | // Tir nan Og | |
+ | addMarkerByAddress("200 Ontario St Kingston Ontario K7L 2Y9","Tir Nan Og Irish Pub","description here"); | ||
} | } | ||
// --></script> | // --></script> | ||
</html> | </html> |
Revision as of 01:01, 25 October 2010