consbio / L.Control.Shapefile

A shapefile uploading control for Leaflet
6 stars 6 forks source link

L.Control.Shapefile

A shapefile uploading control for Leaflet.

Push the upload button, browse to a zipped shapefile, and it will display in your map.

Tested with Leaflet 1.0.

Usage

Include Leaflet and shapefile-js in the head of your webpage.

Include L.Control.Shapefile.js and L.Control.CSS in your webpage after the body tag.

Create the leaflet map

var map = L.map('map').setView([43.5,-116.9], 13);

Add the control

L.control.shapefile({ position: 'topleft' }).addTo(map);

See map.html as an example. There is a sample shapefile in the shp directory that can be used for testing.

Credits

Uses shapefile-js to convert the shapefile to GeoJSON.

Contributors

Mike Gough