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

indigoxela's picture

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

"OpenLayers Integration - For more advanced and flexible data display you need to configure or create a map in OpenLayers at /admin/structure/openlayers/maps. You can easily create your own map by cloning an existing one. An introduction to OpenLayers can be found here..."

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...

indigoxela's picture

for instance, to set up a layer for water basins and another for mining concessions...

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_type to overlay.