Skip to content

Instantly share code, notes, and snippets.

@dexterous
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dexterous/0516f6e64db6572a0ecc to your computer and use it in GitHub Desktop.
Save dexterous/0516f6e64db6572a0ecc to your computer and use it in GitHub Desktop.
A quick US Land usage point map I whipped up using Google Maps JS API, currently hosted at http://us-land-usage-by-state.divshot.io/ .
/.divshot-cache
{
"name": "us-land-usage-by-state",
"root": "./",
"clean_urls": true
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
caption { text-decoration: underline; font-size: 12px; font-weight: bold }
#map-canvas { height: 100% }
.info-window { font-size: 10px }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA_utZWAvhCx_GlICGpRq8Rk-TkDkv7z2A">
</script>
</head>
<body>
<div id="map-canvas"/>
<script type="text/javascript" src="/land-usage.js"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function() {
var map = new google.maps.Map(
document.getElementById('map-canvas'),
{ zoom: 4, center: new google.maps.LatLng(43, -100) }
);
var locator = new google.maps.Geocoder();
for(i = 0; i < data.length; i++) {
setTimeout(function(state) { return function() { state.markOn(map, locator) } }(new State(data[i])), i * 1000);
}
});
function State(state) {
this.markOn = function(map, locator) {
locateWith(locator, function(location) { addToMap(map, location) });
}
var locateWith = function(locator, found) {
locator.geocode({
address: state.capital + ', ' + state.code,
region: 'US'
}, function(responses, status) {
if(status == google.maps.GeocoderStatus.OK) {
console.log('Found coordinates for ' + state.name );
found(responses[0].geometry.location);
} else {
console.log('Geocoding failed for ' + state.name + ': ' + status);
}
});
}
var addToMap = function(map, location) {
var marker = new google.maps.Marker({
map: map,
position: location,
title: state.name,
animation: google.maps.Animation.DROP
});
var info = new google.maps.InfoWindow({ content: landUsageAsHTML() });
google.maps.event.addListener(marker, 'click', function() { info.open(map, marker); });
}
var landUsageAsHTML = function() {
var landUsageString = '<table class="info-window"><caption>' + state.name + '</caption>';
for(usageProp in state.landUsage) {
landUsageString += '<tr><td>' + usageProp + '</td><td>' + state.landUsage[usageProp] + '</td></tr>';
}
landUsageString += '</table>'
return landUsageString;
}
return this;
}
</script>
</body>
</html>
this.data = [
{ name: 'Alabama' , code: 'AL', capital: 'Montgomery' , landUsage: { Total: 33424 , Crop: 7.5 , Range: 0.2 , Forest: 64.4 } },
{ name: 'Alaska' , code: 'AK', capital: 'Juneau' , landUsage: { } },
{ name: 'Arizona' , code: 'AZ', capital: 'Phoenix' , landUsage: { Total: 72964 , Crop: 1.3 , Range: 44.2, Forest: 5.7 } },
{ name: 'Arkansas' , code: 'AR', capital: 'Little Rock' , landUsage: { Total: 34037 , Crop: 22.1, Range: 0.1 , Forest: 44.1 } },
{ name: 'California' , code: 'CA', capital: 'Sacramento' , landUsage: { Total: 101510, Crop: 9.3 , Range: 17.5, Forest: 13.7 } },
{ name: 'Colorado' , code: 'CO', capital: 'Denver' , landUsage: { Total: 66625 , Crop: 12.5, Range: 37.2, Forest: 4.9 } },
{ name: 'Connecticut' , code: 'CT', capital: 'Hartford' , landUsage: { Total: 3195 , Crop: 5.4 , Range: 0 , Forest: 53.4 } },
{ name: 'Delaware' , code: 'DE', capital: 'Dover' , landUsage: { Total: 1534 , Crop: 29.8, Range: 0 , Forest: 22.2 } },
{ name: 'Florida' , code: 'FL', capital: 'Tallahassee' , landUsage: { Total: 37534 , Crop: 7.7 , Range: 7.2 , Forest: 33.9 } },
{ name: 'Georgia' , code: 'GA', capital: 'Atlanta' , landUsage: { Total: 37741 , Crop: 11 , Range: 0 , Forest: 58 } },
{ name: 'Hawaii' , code: 'HI', capital: 'Honolulu' , landUsage: { } },
{ name: 'Idaho' , code: 'ID', capital: 'Boise' , landUsage: { Total: 53488 , Crop: 10.2, Range: 12 , Forest: 7.5 } },
{ name: 'Illinois' , code: 'IL', capital: 'Springfield' , landUsage: { Total: 36059 , Crop: 66.5, Range: 0 , Forest: 11 } },
{ name: 'Indiana' , code: 'IN', capital: 'Indianapolis' , landUsage: { Total: 23158 , Crop: 57.5, Range: 0 , Forest: 16.5 } },
{ name: 'Iowa' , code: 'IA', capital: 'Des Moines' , landUsage: { Total: 36017 , Crop: 70.8, Range: 0 , Forest: 6.4 } },
{ name: 'Kansas' , code: 'KA', capital: 'Topeka' , landUsage: { Total: 52661 , Crop: 50.3, Range: 30.1, Forest: 2.9 } },
{ name: 'Kentucky' , code: 'KY', capital: 'Frankfurt' , landUsage: { Total: 25863 , Crop: 21.2, Range: 0 , Forest: 40.6 } },
{ name: 'Louisiana' , code: 'LA', capital: 'Baton Rouge' , landUsage: { Total: 31377 , Crop: 17.3, Range: 0.9 , Forest: 42.5 } },
{ name: 'Maine' , code: 'ME', capital: 'Augusta' , landUsage: { Total: 20966 , Crop: 1.8 , Range: 0 , Forest: 84 } },
{ name: 'Maryland' , code: 'MD', capital: 'Annapolis' , landUsage: { Total: 7870 , Crop: 19.3, Range: 0 , Forest: 30.1 } },
{ name: 'Massechusetts' , code: 'MA', capital: 'Boston' , landUsage: { Total: 5339 , Crop: 4.7 , Range: 0 , Forest: 49.9 } },
{ name: 'Michigan' , code: 'MI', capital: 'Lansing' , landUsage: { Total: 37349 , Crop: 21.7, Range: 0 , Forest: 44.7 } },
{ name: 'Minnesota' , code: 'MN', capital: 'St Paul' , landUsage: { Total: 54010 , Crop: 39.1, Range: 0 , Forest: 30.3 } },
{ name: 'Mississippi' , code: 'MS', capital: 'Jackson' , landUsage: { Total: 30527 , Crop: 16.3, Range: 0 , Forest: 54.9 } },
{ name: 'Missouri' , code: 'MO', capital: 'Jefferson City', landUsage: { Total: 44614 , Crop: 30.7, Range: 0.2 , Forest: 28.1 } },
{ name: 'Montana' , code: 'MT', capital: 'Helena' , landUsage: { Total: 94110 , Crop: 15.4, Range: 39 , Forest: 5.7 } },
{ name: 'Nebraska' , code: 'NE', capital: 'Lincoln' , landUsage: { Total: 49510 , Crop: 39.5, Range: 46.6, Forest: 1.6 } },
{ name: 'Nevada' , code: 'NV', capital: 'Carson City' , landUsage: { Total: 70763 , Crop: 0.9 , Range: 11.7, Forest: 0.4 } },
{ name: 'New Hampshire' , code: 'NH', capital: 'Concord' , landUsage: { Total: 5941 , Crop: 2.1 , Range: 0 , Forest: 65.6 } },
{ name: 'New Jersey' , code: 'NJ', capital: 'Trenton' , landUsage: { Total: 5216 , Crop: 10.1, Range: 0 , Forest: 30.8 } },
{ name: 'New Mexico' , code: 'NM', capital: 'Santa Fe' , landUsage: { Total: 77823 , Crop: 2 , Range: 51.3, Forest: 7 } },
{ name: 'New York' , code: 'NY', capital: 'Albany' , landUsage: { Total: 31361 , Crop: 17.1, Range: 0 , Forest: 56.1 } },
{ name: 'North Carolina', code: 'NC', capital: 'Raleigh' , landUsage: { Total: 33709 , Crop: 16.4, Range: 0 , Forest: 45.9 } },
{ name: 'North Dakota' , code: 'ND', capital: 'Bismark' , landUsage: { Total: 45251 , Crop: 53.6, Range: 24.5, Forest: 1 } },
{ name: 'Ohio' , code: 'OH', capital: 'Columbus' , landUsage: { Total: 26445 , Crop: 42.5, Range: 0 , Forest: 27.3 } },
{ name: 'Oklahoma' , code: 'OK', capital: 'Oklahoma City' , landUsage: { Total: 44738 , Crop: 20.1, Range: 31.6, Forest: 16.5 } },
{ name: 'Oregon' , code: 'OR', capital: 'Salem' , landUsage: { Total: 62161 , Crop: 6 , Range: 15.1, Forest: 20.5 } },
{ name: 'Pennsylvania' , code: 'PA', capital: 'Harrisburg' , landUsage: { Total: 28995 , Crop: 17.7, Range: 0 , Forest: 53.9 } },
{ name: 'Rhode Island' , code: 'RI', capital: 'Providence' , landUsage: { Total: 813 , Crop: 2.5 , Range: 0 , Forest: 45.9 } },
{ name: 'South Carolina', code: 'SC', capital: 'Columbia' , landUsage: { Total: 19939 , Crop: 11.9, Range: 0 , Forest: 56 } },
{ name: 'South Dakota' , code: 'SD', capital: 'Pierre' , landUsage: { Total: 49358 , Crop: 34.6, Range: 44.7, Forest: 1 } },
{ name: 'Tennessee' , code: 'TN', capital: 'Nashville' , landUsage: { Total: 26974 , Crop: 17.6, Range: 0 , Forest: 44.3 } },
{ name: 'Texas' , code: 'TX', capital: 'Austin' , landUsage: { Total: 171052, Crop: 14.9, Range: 56.2, Forest: 6.2 } },
{ name: 'Utah' , code: 'UT', capital: 'Salt Lake City', landUsage: { Total: 54339 , Crop: 3.1 , Range: 19.6, Forest: 3.5 } },
{ name: 'Vermont' , code: 'VT', capital: 'Montpelier' , landUsage: { Total: 6154 , Crop: 9.5 , Range: 0 , Forest: 67.1 } },
{ name: 'Virginia' , code: 'VA', capital: 'Richmond' , landUsage: { Total: 27087 , Crop: 10.6, Range: 0 , Forest: 48.7 } },
{ name: 'Washington' , code: 'WA', capital: 'Olympia' , landUsage: { Total: 44035 , Crop: 14.7, Range: 13.3, Forest: 28.9 } },
{ name: 'West Virginia' , code: 'WV', capital: 'Charleston' , landUsage: { Total: 15508 , Crop: 5.3 , Range: 0 , Forest: 68.1 } },
{ name: 'Wisconsin' , code: 'WI', capital: 'Madison' , landUsage: { Total: 35920 , Crop: 28.7, Range: 0 , Forest: 40.4 } },
{ name: 'Wyoming' , code: 'WY', capital: 'Cheyenne' , landUsage: { Total: 62603 , Crop: 3.5 , Range: 44 , Forest: 1.5 } },
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment