How to get the Leaflet Map object (Mapping Module)

I use the Mapping Module and it works well that my items are displayed as points on the map. I know that I can also load WMS layers on the map. However, in my case I only have a GeoJson to draw additional polygons to the items.

My approach is to edit view/omeka/site/page/show.phtml in my theme and use JavaScript there to load the GeoJson on the leaflet map additionally.

However, I am not able to get the map object. I have already tried:

var mappingBlock = L.DomUtil.get($(".leaflet-container")[0]);

var mappingBlock =$(".leaflet-container")[0]);

but that only led to the error:
Uncaught Error: Map container is already initialized.

How can I edit the map with JavaScript afterwards?

You could edit the JS file directly, here.

Thanks for the quick help. I had to edit this file though.
It works now.

Can I copy the file to my theme so that the next time I update the mapping module, it won’t overwrite the changes?

As a feature request it would be great if in the backend at the page there would be an input field in which GeoJSON could be entered?
Sorry for the childish mockup:

Maybe I’ll try it to program it myself and then make a pull request.

I had already some progress:

unfortunately, the form still “forgets” the entered data and does not save them. But I will get that right as well.

I finally have a first version

And the result:

Unfortunately, I have the problem that the GeoJSON is not yet fully generic.
Is my attempt in the right direction and is this feature generally desired? Since I have not yet graduated to Omeka 4 I have developed this with the Mapping Module 1.6.0. But it should also run with the latest version.

Should I make a pull request on github?

Adding a GeoJSON field is an idea we’re considering for a future release. In fact we’re currently working on a major update to the module that introduces Polygon and LineString types. You could submit a PR, but the codebase will be significantly different than the version you’re working on.

1 Like

Hello Omeka-S team … is there a timeline for this enhanced mapping module? Thank you!

The enhanced module is currently in testing. Moreover, it requires an unreleased version of Omeka S. We’ll release the module after it’s been tested and the required version of Omeka S has been released. Probably within the next few months.

1 Like