simonw / datasette-leaflet-geojson

Datasette plugin that replaces any GeoJSON column values with a Leaflet map.
20 stars 8 forks source link

Better error handling when creating maps #23

Closed the-kenny closed 7 months ago

the-kenny commented 10 months ago

This modifies addMap to display an error message in case anything fails while creating the map. This fixes an issue where invalid GeoJSON would prevent maps in "later" rows from being displayed.

simonw commented 10 months ago

This is a great improvement, thanks. Do you have any tips on how I can manually test it?

the-kenny commented 10 months ago

Sure! With this patch, the following SQL when run in Datasette should display an error for the first row and a LineString for the second. Without the patch, it will display an empty map for the first (plus an error in the inspector) and no map at all for the second row.

select '{"type": "MultiLineString"}' as geojson 
UNION ALL
select '{"type": "LineString", "coordinates": [[8,51],[9,52]]}' as geojson
simonw commented 7 months ago

Thanks, that was just what I needed:

CleanShot 2024-04-24 at 22 01 40@2x