This project is not covered by Drupal’s security advisory policy.

I'm a maintainer of the Leaflet Widget module.

While developing the module, I realized, that the geofield is not the right backend to save GeoJSON data.

Geofield always converts and saves geodata in the WKT format. When using the Leaflet Widget module, I had to convert back the WKT data to geojson. But I realized, that a lot if features got lost during the conversion. Especially all layers were merged into a single multipolygon.

Additionally, the geofield does not scale well with large GeoJson files of 5MB an more.

Therefore I decided to save the GeoJson files on the filesystem. This scales well and you can also use the PrivateStreamWrapper if you have private *.json files.

In the frontend attach the GeoJson files via AJAX to the map instead of inline all the data into drupal.settings which makes the pageload way faster.

How to install and use this module

  • Install the module
  • Install dependanicies leaflet and leaflet_widget modules.
  • Create a new field of type "File" on an entity.
  • Enable the FieldWidget "Leaflet GeoJSON Map Widget" on the edit form and configure the widget settings
  • A map will only be displayed if the GeoJson file is smaller than 5MB.
  • In the frontend use the FieldFormatter "Leaflet GeoJSON Map" to display the GeoJson file.

Project information

Releases