Skip to content

Instantly share code, notes, and snippets.

@smokbel
Created March 15, 2018 02:03
Show Gist options
  • Select an option

  • Save smokbel/1d98d7d90597c09f9b3f98ca27562cc1 to your computer and use it in GitHub Desktop.

Select an option

Save smokbel/1d98d7d90597c09f9b3f98ca27562cc1 to your computer and use it in GitHub Desktop.
Topojson-Ontario
license: mit
<!DOCTYPE html>
<html>
<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('qc-map.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