I have set up a website using Leaflet and which loads an archive of one shapefile using Leaflet and calvinmetcalf shapefile.

My shapefile looks like this, after Date2 do come much more coloumns with dates:

ID   Name     Info         Date1        Date2
0   Herald    Active       01.01.2020   02.10.2020
1   Townson   Pending      23.05.2020   08.09.2020
2   Aspen     Not Active   14.03.1990   23.02.1995

I now wanted to show a popup on Leaflet when the user clicks on the polygon. Every "empty" date (where no date is set should be left out).

However apparently I fail to load the one polygon at a time using this code:

var shpfile = new L.Shapefile('./Shapefile.zip', {style: {color: 'red', fillColor: 'blue'}});

Can't I use the standard onEachFeature-method to load one polygon and bind then the information to the polygon?

  • 1
    If you read plugin description at plugin home page github.com/calvinmetcalf/leaflet.shapefile, you'll notice the statement: Options are passed to L.Geojson as is. This means you can use standard L.Geojson options, which includes onEachFeature option. – TomazicM May 26 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.