Skip to content

Instantly share code, notes, and snippets.

@markerdmann
Created March 15, 2010 00:14
Show Gist options
  • Save markerdmann/332360 to your computer and use it in GitHub Desktop.
Save markerdmann/332360 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>SF Plotter</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjU0EJWnWPMv7oQ-jjS7dYxSPW5CJgpdgO_s4yyMovOaVh_KvvhSfpvagV18eOyDWu7VytS6Bi1CWxw"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map;
var geocoder = null;
var addressMarker;
var addresses = [
"27 Harriet St., San Francisco, CA",
"Balboa and Park Presidio, San Francisco, CA",
"282 2nd St., San Francisco, CA",
"Mission and 24th, San Francisco, CA",
"Lincoln and 19th Ave., San Francisco, CA",
"Guerrero and 17th Ave., San Francisco, CA"
];
var numGeocoded = 0;
var boundaries = new GLatLngBounds(new GLatLng(37.707,-122.55), new GLatLng(37.814,-122.33));
var oldmap = new GGroundOverlay("overview.jpg", boundaries);
var geoXml;
function geocodeAll() {
if (numGeocoded < addresses.length) {
geocoder.getLocations(addresses[numGeocoded], addressResolved);
}
}
function addressResolved(response) {
var delay = 0;
if (response.Status.code == 620) {
// Too fast, try again, with a small pause
delay = 500;
} else {
if (response.Status.code == 200) {
// Success; do something with the address.
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
marker = new GMarker(point);
map.addOverlay(marker);
}
// Move onto the next address; this skips bad addresses, too.
numGeocoded += 1;
}
window.setTimeout(geocodeAll, delay);
}
function load() {
if (GBrowserIsCompatible()) {
geoXml = new GGeoXml("http://sites.google.com/site/sfdistricts/home/districts.kml");
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(37.770308,-122.44709), 12);
geocoder = new GClientGeocoder();
geocoder.setCache(null);
window.setTimeout(geocodeAll, 50);
map.addOverlay(geoXml);
}
}
function DistrictsOff() {
map.removeOverlay(geoXml);
}
function DistrictsOn() {
map.addOverlay(geoXml);
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 1000px; height: 600px"></div>
District Overlay
<button type=button onclick="DistrictsOn()">On</button>
<button type=button onclick="DistrictsOff()">Off</button>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment