From GamingWiki
| (68 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | <script type="text/javascript"> alert(" | + | <includeonly> |
| + | </includeonly> | ||
| + | <html> | ||
| + | <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> | ||
| + | <script type="text/javascript"><!-- | ||
| + | /** | ||
| + | * Google Maps overlay for Kingston: Ghost Town | ||
| + | * | ||
| + | * This is the driver for the map overlay for the Dresden Files campaign, | ||
| + | * "Ghost Town". We put various important locations on this map. | ||
| + | * | ||
| + | * Google Maps API documentation: | ||
| + | * http://code.google.com/apis/maps/documentation/javascript/ | ||
| + | * Reference docs: | ||
| + | * http://code.google.com/apis/maps/documentation/javascript/reference.html | ||
| + | */ | ||
| + | |||
| + | // Initialization | ||
| + | |||
| + | var geocoder; | ||
| + | var map; | ||
| + | var infowindow; | ||
| + | var markers = new Array(); | ||
| + | |||
| + | function initialize() { | ||
| + | var myLatlng = new google.maps.LatLng(44.24,-76.5); | ||
| + | var myOptions = { | ||
| + | zoom: 13, | ||
| + | center: myLatlng, | ||
| + | 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); | ||
| + | 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); | ||
| + | }); | ||
| + | } | ||
| + | /** | ||
| + | * 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); | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Add markers by address | ||
| + | */ | ||
| + | function addMarkerByAddress(address, title, descId) { | ||
| + | if (geocoder) { | ||
| + | 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); | ||
| + | } | ||
| + | }); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Set up the various locations in Ghost Town, to be placed on the map. | ||
| + | */ | ||
| + | function getMarkerList() { | ||
| + | for ( i = 0; i < markers.length; i++ ) { | ||
| + | marker = markers[i]; | ||
| + | if (typeof marker['address'] === 'undefined' || marker['address'] == '') { | ||
| + | addMarkerByLatLng(marker['lat'], marker['lng'], marker['name'], marker['node']); | ||
| + | } else { | ||
| + | addMarkerByAddress(marker['address'], marker['name'], marker['node']); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // --></script> | ||
| + | </html> | ||
Latest revision as of 17:55, 17 March 2011