From GamingWiki
Jump to: navigation, search
 
(56 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 18: Line 20:
 
var geocoder;
 
var geocoder;
 
var map;
 
var map;
 +
var infowindow;
 +
var markers = new Array();
  
 
function initialize() {
 
function initialize() {
Line 26: Line 30:
 
mapTypeId: google.maps.MapTypeId.ROADMAP
 
mapTypeId: google.maps.MapTypeId.ROADMAP
 
}
 
}
 +
geocoder = new google.maps.Geocoder();
 +
infowindow = new google.maps.InfoWindow({maxWidth: 256});
 
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
geocoder = new google.maps.Geocoder();
 
 
getMarkerList();
 
getMarkerList();
 
}
 
}
Line 33: Line 38:
 
google.maps.event.addDomListener(window, 'load', initialize);
 
google.maps.event.addDomListener(window, 'load', initialize);
  
// Helper function
+
/**
function addMarkerByLatLng(lat, lng, title, description) {
+
* Add a marker to the map
var latlng = new google.maps.LatLng(lat, lng);
+
*/
 +
function addMarker(latlng, title, descId) {
 
var marker = new google.maps.Marker({position:latlng, map: map, title:title});
 
var marker = new google.maps.Marker({position:latlng, map: map, title:title});
var infowindow = new google.maps.InfoWindow({
+
google.maps.event.addListener(marker, "click", function() {  
content: "<div class=\"mapmarker\">\n" + description + "\n</div>"
+
infowindow.setContent(document.getElementById(descId).innerHTML);
 +
infowindow.open(map,marker);
 
});
 
});
google.maps.event.addListener(marker, "click", function() { infowindow.open(map,marker); });
+
}
return 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);
 
}
 
}
  
Line 47: Line 59:
 
  * Add markers by address
 
  * Add markers by address
 
  */
 
  */
function addMarkerByAddress(address, title, description) {
+
function addMarkerByAddress(address, title, descId) {
 
if (geocoder) {
 
if (geocoder) {
geocoder.getLatLng({request:address, callback:function(latlng) {
+
geocoder.geocode({'address':address}, function(results, status) {
if (!latlng) {
+
if (status == google.maps.GeocoderStatus.OK) {
alert(address + " not found");
+
var latlng = results[0].geometry.location;
 +
addMarker(latlng, title, descId);
 
} else {
 
} else {
var marker = new google.maps.Marker({position:latlng, map:map, title:name});
+
alert(address + " not found: "+results[0]+"; "+status);
google.maps.event.addListener(marker, "click", function() { infowindow.open(map,marker); });
 
 
}
 
}
}});
+
});
 
}
 
}
 
}
 
}
Line 64: Line 76:
 
  */
 
  */
 
function getMarkerList() {
 
function getMarkerList() {
// The Purple Door
+
for ( i = 0; i < markers.length; i++ ) {
addMarkerByLatLng(44.234807,-76.490271,
+
marker = markers[i];
"The Purple Door",
+
if (typeof marker['address'] === 'undefined' || marker['address'] == '') {
"<p><b>The Purple Door Books &amp; Gifts</b></p> " +
+
addMarkerByLatLng(marker['lat'], marker['lng'], marker['name'], marker['node']);
"<p><b>Aspect: <span class=\"aspect\">Struggling to stay open</span></b> " +
+
} else {
"Threats of foreclosure have been hounding the Purple Door, and causing "+
+
addMarkerByAddress(marker['address'], marker['name'], marker['node']);
"its proprietor, Madame Esmerelda, to scramble to keep it open. "
+
}
);
+
}
 
 
// Woolen mill
 
addMarkerByLatLng(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
 
addMarkerByLatLng(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> "
 
);
 
 
 
// Tir nan Og
 
addMarkerByAddress("200 Ontario St Kingston Ontario K7L 2Y9","Tir Nan Og Irish Pub","description here");
 
 
}
 
}
  
 
// --></script>
 
// --></script>
 
</html>
 
</html>

Latest revision as of 17:55, 17 March 2011