From GamingWiki
Jump to: navigation, search
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
 
}
 
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
+
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var markers = getMarkerList(map);
+
geocoder = new GClientGeocoder();
//for (i = 0; i < len(markers); i++) { marker.setMap(map); }
+
getMarkerList();
 
}
 
}
 
+
// Initialize on page load
function loadScript() {
+
google.maps.event.addDomListener(window, 'load', initialize);
var script = document.createElement("script");
 
script.type = "text/javascript";
 
script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
 
document.body.appendChild(script);
 
}
 
  google.maps.event.addDomListener(window, 'load', initialize);
 
  
  /*
 
window.onload = loadScript;
 
*/
 
 
// Helper function
 
// Helper function
function mkMarker(map, lat, lng, mrkTitle, html) {
+
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: mrkTitle});
+
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" + html + "\n</div>"
+
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); });
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(map) {
+
function getMarkerList() {
var locations = new Array();
 
 
 
 
// The Purple Door
 
// The Purple Door
locations.push(mkMarker(map, 44.234807,-76.490271,  
+
addMarkerByLatLng(44.234807,-76.490271,  
 
"The Purple Door",  
 
"The Purple Door",  
 
"<p><b>The Purple Door Books &amp; Gifts</b></p> " +
 
"<p><b>The Purple Door Books &amp; 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
locations.push(mkMarker(map, 44.242524,-76.482053,
+
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
locations.push(mkMarker(map, 44.228188,-76.496108,
+
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> "
));
+
);
  
return locations;
+
// 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