-
-
Save friedbunny/5546480 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Leaflet TopoJSON Example</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
<link rel="stylesheet" href="//cdn.leafletjs.com/leaflet-0.5.1/leaflet.css" /> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
<script src="//cdn.leafletjs.com/leaflet-0.5.1/leaflet.js"></script> | |
<script src="http://d3js.org/topojson.v1.js"></script> | |
<style> | |
body { | |
padding: 0; | |
margin: 0; | |
} | |
html, body, #map { | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script src="some-javascripts.js"></script> | |
</body> | |
</html> |
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
var county_layer = L.geoJson(null, { | |
style: { | |
color: '#666', | |
weight: 1, | |
opacity: 1, | |
fillOpacity: 0.3 | |
} | |
}), | |
state_layer = L.geoJson(null, { | |
style: { | |
color: '#333', | |
weight: 3, | |
opacity: 1, | |
fillOpacity: 0 | |
} | |
}), | |
map = L.map('map'); | |
L.tileLayer('http://{s}.tiles.mapbox.com/v3/examples.map-4l7djmvo/{z}/{x}/{y}.png', { | |
maxZoom: 17, | |
attribution: 'Map data © MapBox, OSM', | |
}).addTo(map); | |
map | |
.addLayer(county_layer) | |
.addLayer(state_layer) | |
.setView([40, -100], 5); | |
$.getJSON('us_counties.json', function (data) { | |
var county_geojson = topojson.feature(data, data.objects.counties), | |
state_geojson = topojson.feature(data, data.objects.states); | |
county_layer.addData(county_geojson); | |
state_layer.addData(state_geojson); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sdafasfdsdafasdfa