Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save zross/11184494 to your computer and use it in GitHub Desktop.
Put topojson on LeafletJS map
<meta charset="utf-8" />
<meta name="viewport" content="width=650, user-scalable=yes">
<script src=""></script>
<link rel="stylesheet" href="" />
<script src=""></script>
<script src=""></script>
html, body {
height: 100%;
margin: 0;
var geoJsonObject;
map = new L.Map('mapcanvas');
var osmUrl='http://{s}{z}/{x}/{y}.png';
var osmAttrib='Map data © <a href="">OpenStreetMap</a> contributors';
var osm = new L.TileLayer(osmUrl, {attribution: osmAttrib});
// start the map in South-East England
map.setView(new L.LatLng(36.788283, -119.805891),6);
//county.json is a topojson file
var myStyle = {
"color": "#003399",
"weight": 1,
"opacity": 0.65
$.getJSON("township.json", function(data){
geoJsonObject = topojson.feature(data, data.objects.township)
});//end document ready
<div id="mapcanvas">
Display the source blob
Display the rendered blob
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