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
/* | |
You'll need something like this in your HTML: | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
*/ | |
L.TopoJSON = L.GeoJSON.extend({ | |
addData: function(jsonData) { | |
if (jsonData.type === "Topology") { | |
for (key in jsonData.objects) { | |
geojson = topojson.feature(jsonData, jsonData.objects[key]); |
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
L.GeoJSON.include({ | |
setOptions: function(opts) { | |
//save original json data | |
this._data = this._data || this.toGeoJSON(); | |
//destory layer group | |
this.clearLayers(); | |
L.setOptions(this, opts); | |
//recreate layer group |
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
L.GeoJSON.include({ | |
identify: function(latlng) { | |
var features = new L.FeatureGroup(), | |
geopoint = { | |
type: 'Point', | |
coordinates: [latlng.lng, latlng.lat] | |
}; | |
this.eachLayer(function (layer) { | |
if (gju.pointInPolygon(geopoint, layer.feature.geometry)) { | |
features.addLayer(layer); |