From GamingWiki
Jump to: navigation, search
 
(65 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
<includeonly>
 +
</includeonly>
 
<html>
 
<html>
 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
+
<script type="text/javascript"><!--
 
/**
 
/**
 
  * Google Maps overlay for Kingston: Ghost Town
 
  * Google Maps overlay for Kingston: Ghost Town
Line 15: Line 17:
  
 
// Initialization
 
// Initialization
 +
 +
var geocoder;
 +
var map;
 +
var infowindow;
 +
var markers = new Array();
 +
 
function initialize() {
 
function initialize() {
 
var myLatlng = new google.maps.LatLng(44.24,-76.5);
 
var myLatlng = new google.maps.LatLng(44.24,-76.5);
Line 22: Line 30:
 
mapTypeId: google.maps.MapTypeId.ROADMAP
 
mapTypeId: google.maps.MapTypeId.ROADMAP
 
}
 
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
+
geocoder = new google.maps.Geocoder();
var markers = getMarkerList(map);
+
infowindow = new google.maps.InfoWindow({maxWidth: 256});
//for (i = 0; i < len(markers); i++) { marker.setMap(map); }
+
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 +
getMarkerList();
 +
}
 +
// Initialize on page load
 +
google.maps.event.addDomListener(window, 'load', initialize);
 +
 
 +
/**
 +
* Add a marker to the map
 +
*/
 +
function addMarker(latlng, title, descId) {
 +
var marker = new google.maps.Marker({position:latlng, map: map, title:title});
 +
google.maps.event.addListener(marker, "click", function() {  
 +
infowindow.setContent(document.getElementById(descId).innerHTML);
 +
infowindow.open(map,marker);  
 +
});
 
}
 
}
 
+
/**
function loadScript() {
+
* Add a marker with a lat/lng pair
var script = document.createElement("script");
+
*/
script.type = "text/javascript";
+
function addMarkerByLatLng(lat, lng, title, descId) {
script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
+
var latlng = new google.maps.LatLng(lat, lng);
document.body.appendChild(script);
+
addMarker(latlng, title, descId);
 
}
 
}
 
 
window.onload = loadScript;
 
  
// Helper function
+
/**
function mkMarker(map, lat, lng, mrkTitle, html) {
+
* Add markers by address
var latlng = new google.maps.LatLng(lat, lng);
+
*/
var marker = new google.maps.Marker({position:latlng, map: map, title: mrkTitle});
+
function addMarkerByAddress(address, title, descId) {
var infowindow = new google.maps.InfoWindow({
+
if (geocoder) {
content: "<div class=\"mapmarker\">\n" + html + "\n</div>"
+
geocoder.geocode({'address':address}, function(results, status) {
 +
if (status == google.maps.GeocoderStatus.OK) {
 +
var latlng = results[0].geometry.location;
 +
addMarker(latlng, title, descId);
 +
} else {
 +
alert(address + " not found: "+results[0]+"; "+status);
 +
}
 
});
 
});
google.maps.event.addListener(marker, "click", function() {
+
}
infowindow.open(map,marker);
 
});
 
return marker;
 
 
}
 
}
  
Line 52: Line 75:
 
  * 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();
+
for ( i = 0; i < markers.length; i++ ) {
 
+
marker = markers[i];
// The Purple Door
+
if (typeof marker['address'] === 'undefined' || marker['address'] == '') {
locations.push(mkMarker(map, 44.234807,-76.490271,
+
addMarkerByLatLng(marker['lat'], marker['lng'], marker['name'], marker['node']);
"The Purple Door",
+
} else {
"<p><b>The Purple Door Books &amp; Gifts</b></p> " +
+
addMarkerByAddress(marker['address'], marker['name'], marker['node']);
"<p><b>Aspect: <span class=\"aspect\">Struggling to stay open</span></b> " +
+
}
"Threats of foreclosure have been hounding the Purple Door, and causing "+
+
}
"its proprietor, Madame Esmerelda, to scramble to keep it open. "
 
));
 
 
 
// Woolen mill
 
locations.push(mkMarker(map, 44.242524,-76.482053,
 
"The Woolen Mill",
 
"<p><b>The Woolen Mill</b></p> " +
 
"<p><b>Aspect: <span class=\"aspect\">Working to obsolete itself</span></b> " +
 
"The Woolen Mill is an office building in downtown Kingston that houses, " +
 
"among other companies and agencies, a StarTek call centre.</p> "
 
));
 
 
 
// Queen's Library
 
locations.push(mkMarker(map, 44.228188,-76.496108,
 
"Joseph S. Stauffer Library",
 
"<p><b>Joseph S. Stauffer Library</b></p> " +
 
"<p><b>Aspect: <span class=\"aspect\"></span></b> " +
 
"This is the main library at Queen's University. " +
 
"Any book mentioning the occult or the supernatural has been lost, stolen " +
 
"or defaced.</p> "
 
));
 
 
 
return dw_locations;
 
 
}
 
}
  
</script>
+
// --></script>
 
</html>
 
</html>

Latest revision as of 17:55, 17 March 2011