Hello. I've been looking for some orientation on the web on how to implement and manage overlay layers in leaflet. It seems that in Drupal the contrib module OpenLayers deals with it, but as I don't see that module available in Backdrop, I was hoping to have some orientation from you guys. Thank you.
Comments
Hi jcesar,
it may depend on what kind overlay you need. Overlays are supported in the Leaflet module.
The submodule leaflet_more_maps ships with a lot of additional map types. And there's some user interface to combine layers there.
If you need something entirely custom, you can use a hook for that.
If you only need to slightly adapt an existing map, there's another hook for that - hook_leaflet_map_prebuild_alter(). More likely that's what you're after.
I never used OpenLayers, so I can't describe the differences, nor what it takes to migrate existing code.
Thanks for replying. I was expecting that it be relatively easy to manage overlay layers (not the base layers that are indeed controlled form the Leaflet More Maps module's settings page). That is, for instance, to set up a layer for water basins and another for mining concessions, so as to make them switchable with check buttons from the layer menu.
Although the "Project details" page on the install modules instance talks about having
There really isn't such integration, no /admin/structure/openlayers/ section whatsoever or its equivalent anywhere. I think it's only possible right now with direct scripting...
We were able to add overlays and polygons to leaflet with a custom module as mentioned in https://github.com/backdrop-contrib/leaflet/issues/73#issuecomment-2907873081 with a combination of php and js, but have not put this together as a tutorial.
Are those tiles from a tile server, or some GeometryCollection in local file in json format? And you want to use the layer toggle in the top right corner?
In Leaflet overlay layers are just layers, too. You'd just set
layer_typetooverlay.