Last active
August 29, 2015 14:19
-
-
Save kuno/915915f22b1c95b5e6f2 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> | |
<meta charset="utf-8"> | |
<body> | |
<div id="map"></div> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script src="http://api.tiles.mapbox.com/mapbox.js/v1.0.3/mapbox.js"></script> | |
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.0.3/mapbox.css' rel='stylesheet' /> | |
<style> | |
body { margin:0; padding:0; } | |
#map { position:absolute; top:0; bottom:0; width:100%; } | |
</style> | |
<script> | |
L.mapbox.accessToken = '<Your public token>'; | |
var map = L.mapbox.map('map', 'examples.map-i86nkdio').setView([44, -100], 2), | |
layer = L.geoJson(null, { style: { color: '#000', weight: 1 }}) | |
var AFG_Central_AGG001 = [276, 284, 286, 291, 297, 301, 302]; | |
var AFG_East_AGG002 = [290, 292]; | |
var AFG_North_East_AGG003 = [272, 274, 288, 289, 294, 3719, 300]; | |
var AFG_North_West_AGG004 = [275, 278, 283, 298, 299]; | |
var AFG_South_East_AGG005 = [279, 287, 295, 296]; | |
var AFG_South_West_AGG006 = [3784, 281, 285, 293, 303]; | |
var AFG_West_AGG007 = [273, 277, 280, 282]; | |
map.addLayer(layer) | |
d3.json('/data/example/topojson/AFG.topojson', function(error, data) { | |
var center = data.objects.AFG.geometries.filter(function(d) { return AFG_Central_AGG001.indexOf(d.properties.ADM1_CODE) !== -1 }); | |
var east = data.objects.AFG.geometries.filter(function(d) { return AFG_East_AGG002.indexOf(d.properties.ADM1_CODE) !== -1 }); | |
var north_east = data.objects.AFG.geometries.filter(function(d) { return AFG_North_East_AGG003.indexOf(d.properties.ADM1_CODE) !== -1 }); | |
var north_west = data.objects.AFG.geometries.filter(function(d) { return AFG_North_West_AGG004.indexOf(d.properties.ADM1_CODE) !== -1 }); | |
var south_east = data.objects.AFG.geometries.filter(function(d) { return AFG_South_East_AGG005.indexOf(d.properties.ADM1_CODE) !== -1 }); | |
var south_west = data.objects.AFG.geometries.filter(function(d) { return AFG_South_West_AGG006.indexOf(d.properties.ADM1_CODE) !== -1 }); | |
var west = data.objects.AFG.geometries.filter(function(d) { return AFG_West_AGG007.indexOf(d.properties.ADM1_CODE) !== -1 }); | |
layer.addData(topojson.merge(data, center)); | |
layer.addData(topojson.merge(data, east)); | |
layer.addData(topojson.merge(data, north_east)); | |
layer.addData(topojson.merge(data, north_west)); | |
layer.addData(topojson.merge(data, south_east)); | |
layer.addData(topojson.merge(data, south_west)); | |
layer.addData(topojson.merge(data, west)); | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment