Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Forked from JasonSanford/index.html
Last active December 25, 2015 16:58
Show Gist options
  • Save wboykinm/7009366 to your computer and use it in GitHub Desktop.
Save wboykinm/7009366 to your computer and use it in GitHub Desktop.
<!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="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script src="http://d3js.org/topojson.v1.min.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>
var county_layer = L.geoJson(null, {
style: {
color: '#e2e3e3',
weight: 1,
opacity: 1,
fillOpacity: 0.3
}
}),
state_layer = L.geoJson(null, {
style: {
color: '#fff',
weight: 3,
opacity: 1,
fillOpacity: 0
}
}),
map = L.map('map');
L.tileLayer('http://{s}.tiles.mapbox.com/v3/landplanner.map-oxe99jxb/{z}/{x}/{y}.png', {
maxZoom: 17,
attribution: 'Map data &copy; Someone, Somewhere.',
}).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);
});
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment