Created
January 10, 2014 10:21
-
-
Save neilkennedy/8349663 to your computer and use it in GitHub Desktop.
Use JSTS buffer function with Leaflet.js by exporting / importing GeoJSON
This file contains hidden or 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
function buffer(leafletGeometry, distance){ | |
var reader, input, buffer, bufferGeoJSON; | |
reader = new jsts.io.GeoJSONReader(); | |
input = reader.read(leafletGeometry.toGeoJSON()); | |
buffer = input.geometry.buffer(distance); | |
bufferGeoJSON = new jsts.io.GeoJSONWriter().write(buffer); | |
return L.geoJson(bufferGeoJSON); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment