Created
February 23, 2009 15:31
-
-
Save bcalloway/68996 to your computer and use it in GitHub Desktop.
Google Map API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="map"></div> | |
<script type="text/javascript"> | |
// Create a base icon | |
var baseIcon = new GIcon(); | |
baseIcon.image = "images/red_marker.png"; | |
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png"; | |
baseIcon.iconSize = new GSize(20, 34); | |
baseIcon.shadowSize = new GSize(37, 34); | |
baseIcon.iconAnchor = new GPoint(9, 34); | |
baseIcon.infoWindowAnchor = new GPoint(9, 2); | |
baseIcon.infoShadowAnchor = new GPoint(18, 25); | |
function createMarker(point, index, city) { | |
var letteredIcon = new GIcon(baseIcon); | |
markerOptions = { | |
icon:letteredIcon, | |
labelText: index, | |
labelClass: "glabel", | |
labelOffset: new GSize(-6, -32) | |
}; | |
var marker = new LabeledMarker(point, markerOptions); | |
// Go to town page if icon is clicked | |
GEvent.addListener(marker, "click", function() { | |
window.location = city + ".html" | |
}); | |
return marker; | |
} | |
if (GBrowserIsCompatible()) { | |
var map = new GMap2(document.getElementById("map")); | |
map.setCenter(new GLatLng(35.600, -82.554), 8); | |
map.addControl(new GSmallMapControl()); | |
map.addControl(new GMapTypeControl()); | |
//Change this to set base map to terrain | |
//map.setMapType(G_PHYSICAL_MAP); | |
//map.addMapType(G_PHYSICAL_MAP); | |
//Markers, label text, and city name for each marker | |
// GLatLng defined the point, the label text is overlayed on the marker, and the city name is the pagename to link | |
// example: map.addOverlay(createMarker(new GLatLng(lat, lng), label, city-name)) | |
map.addOverlay(createMarker(new GLatLng(35.5, -82.57),1,'Asheville')) | |
map.addOverlay(createMarker(new GLatLng(36.15, -81.89),2,'Banner-Elk')) | |
map.addOverlay(createMarker(new GLatLng(35.6, -82.34),3,'Black-Mountain')) | |
map.addOverlay(createMarker(new GLatLng(36.13, -81.67),4,'Blowing-Rock')) | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment