Last active
August 29, 2015 14:26
-
-
Save mapsense-examples/02044c0685edf5d60c72 to your computer and use it in GitHub Desktop.
Bounded Voronoi
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> | |
<meta charset="utf-8"> | |
<meta name="viewport" content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<script src="http://d3js.org/topojson.v1.min.js" charset="utf-8"></script> | |
<script src="https://developer.mapsense.co/mapsense.js" charset="utf-8"></script> | |
<link type="text/css" href="https://developer.mapsense.co/mapsense.css" rel="stylesheet"/> | |
<style> | |
html, body, #myMap{ | |
height: 100%; | |
width: 100%; | |
margin: 0; padding: 0; | |
} | |
.map { | |
background-color: white; | |
width: 100%; | |
height: 100%; | |
} | |
.mapFeatures { | |
vector-effect: non-scaling-stroke; | |
stroke: grey; | |
fill : none; | |
} | |
.tile-background { | |
fill: white; | |
} | |
.cell{ | |
fill: rgba(0,0,0,.5); | |
stroke: rgba(68, 167, 228, 1); /*blue*/ | |
} | |
.cell:hover{ | |
fill: rgba(0,0,0,.2); | |
cursor: pointer; | |
} | |
.seed{ | |
fill: steelblue; | |
fill-opacity: .8; | |
stroke: white; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="myMap"></div> | |
<script> | |
// Extent of map | |
var us = [ | |
{lon: -124.8, lat: 25.0}, | |
{lon: -67, lat: 49.5} | |
]; | |
var map = mapsense.map("#myMap"); //tell it where to go | |
map.add( | |
mapsense.basemap() | |
.apiKey("key-2d5eacd8b924489c8ed5e8418bd883bc") | |
) | |
.extent(us); | |
// Add geojsons | |
d3.json("voronoi.geojson", function(data){ | |
map.add(mapsense.geoJson() | |
.features(data.features) | |
.selection(function(d){ | |
d.attr("class", "cell"); | |
}) | |
); | |
d3.json("points.geojson", function(data){ | |
map.add(mapsense.geoJson() | |
.features(data.features) | |
.selection(function(d){ | |
d.attr("class", "seed"); | |
}) | |
); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment