From GamingWiki
Jump to: navigation, search
 
(59 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>
Line 15: Line 17:
  
 
// Initialization
 
// Initialization
 +
 +
var geocoder;
 +
var map;
 +
var infowindow;
 +
var markers = new Array();
  
 
function initialize() {
 
function initialize() {
Line 23: 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
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";
+
* Add a marker to the map
document.body.appendChild(script);
+
*/
 +
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);
 +
});
 +
}
 +
/**
 +
* Add a marker with a lat/lng pair
 +
*/
 +
function addMarkerByLatLng(lat, lng, title, descId) {
 +
var latlng = new google.maps.LatLng(lat, lng);
 +
addMarker(latlng, title, descId);
 
}
 
}
  google.maps.event.addDomListener(window, 'load', initialize);
 
  
  /*
+
/**
window.onload = loadScript;
+
* Add markers by address
*/
+
*/
// Helper function
+
function addMarkerByAddress(address, title, descId) {
function mkMarker(map, lat, lng, mrkTitle, html) {
+
if (geocoder) {
var latlng = new google.maps.LatLng(lat, lng);
+
geocoder.geocode({'address':address}, function(results, status) {
var marker = new google.maps.Marker({position:latlng, map: map, title: mrkTitle});
+
if (status == google.maps.GeocoderStatus.OK) {
var infowindow = new google.maps.InfoWindow({
+
var latlng = results[0].geometry.location;
content: "<div class=\"mapmarker\">\n" + html + "\n</div>"
+
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 55: 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 locations;
 
 
}
 
}
  
 
// --></script>
 
// --></script>
 
</html>
 
</html>

Latest revision as of 17:55, 17 March 2011