Last active
December 20, 2015 11:39
-
-
Save js1568/6124574 to your computer and use it in GitHub Desktop.
Leaflet Identify function (similar to ESRI ArcGIS Javascript API function) for finding polygons based on a given latlng from in a L.GeoJson feature layer group.Requires Leaflet and geojson-js-utils: https://github.com/maxogden/geojson-js-utils
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); | |
} | |
}); | |
return features; | |
} | |
}); |
You could have written L.GeoJSON.include({...})
:)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example for use: