UPDATE: Starting with the version 1.3.14, it will be possible to add custom JS directly in the plugin settings. Go to Open User Map > Settings > Advanced > Custom JS
You can trigger a number of Javascript functions. Here are some possible use cases.
Reload the map
This may be helpful if you are using a Caching or Page Preloading Plugin. Sometimes the preloading blocks the loading of the OUM map, so that it needs to be reloaded.
oumMap.invalidateSize();
Fly to another location
Use the following JS function after your page has loaded. The necessary parameters are latitude, longitude and zoom.
oumMap.flyTo([40.737, -73.923], 8);
Fly to the current user position
Use the following JS function to trigger a click on the “Show me where I am” Button.
document.querySelector('.leaflet-control-locate a').click();
Open the “Add location” form
Use the following JS function to trigger a click on the “+” Button to open the “Add location” form.
document.querySelector('#open-add-location-overlay').click();
Activate/Deactivate a Marker Category
Use the following JS function to trigger a click on a marker category. The number (e.g. “3”) is the position of the category in the category list.
document.querySelector('.leaflet-control-layers-overlays label:nth-child(3)').click();
To activate or deactivate all marker categories at the same time you can use this snippet:
document.querySelectorAll('.leaflet-control-layers-overlays label').forEach((category) => {
category.click()
});