Skip to content

Instantly share code, notes, and snippets.

@smokbel
Last active March 15, 2018 02:30
Show Gist options
  • Select an option

  • Save smokbel/5bd4d590a410e9cb9ef438a091773777 to your computer and use it in GitHub Desktop.

Select an option

Save smokbel/5bd4d590a410e9cb9ef438a091773777 to your computer and use it in GitHub Desktop.
ont-map
license: mit
<!DOCTYPE html>
<html>
<h1>Ontario subdivision map</h1>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/3.0.2/topojson.js"></script>
<style>
#ont {
fill: lightGrey;
stroke: grey;
}
</style>
<body>
<div id="map"></div>
<script>
var width = 960, height = 700;
var svg = d3.select('#map').append('svg')
.attr('width', width)
.attr('height', height)
d3.json('ont.json', function(error, CensusSubDiv) {
if (error) return console.error(error);
var featureCollection = topojson.feature(CensusSubDiv, CensusSubDiv.objects.CensusSubDivision)
var projection = d3.geoIdentity()
.reflectY(true)
.fitSize([width,height],featureCollection)
svg.append('path')
.datum(featureCollection)
.attr('d', d3.geoPath().projection(projection))
.attr('id', 'ont');
});
</script>
Display the source blob
Display the rendered blob
Raw
Loading
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