The plugin provides some Javascript methods and events available publicly to be used in your custom code, if needed.
Most likely you will need the Map ID in your code. You can find the map ID for each one in the administration archive for the maps you created. Most methods will be accessible through the iMapsManager object.
Events
When the map is loaded it triggers the ‘mapready‘ event in the map container. You can use code like this to listen to it:
// replace with your map ID. let mapID = 21148; let mapContainer = document.getElementById('map_' + mapID); mapContainer.addEventListener('mapready',function(ev){ // map is loaded. your code here });
You can use the above code to run code only after the map has loaded.
Methods
Select
Triggering a select event on a region will simulate a click on it. So if you have events attached to those regions, they will be executed.
Name | Description | Examples |
| Triggers select event on selected entries. |
|
| Clears all hovered entries in selected map. |
|
| Gets the list of currently hovered entries. |
|
When selecting other entry, the map will automatically clear previously selected entries.
Hover
Triggering the hover event will usually change the region or marker colour and show the tooltip. You can trigger the hover event in multiple regions, but it will probably only display the tooltip in the first or last. If you have events in the map attached to the hover event, they will also be triggered.
Name | Description | Examples |
| Triggers hover event on selected entries. |
|
| Clears all hovered entries in selected map. |
|
| Gets the list of currently hovered entries. |
|
When using the hover event in your own custom elements, it would be important to also use the clearHovered
method when hovering out your custom elements, so that it doesn’t stay with that state.
Highlight
The highlight event is similar to the hover event, but it will not trigger the tooltip or any other associated event with that region or marker. It will simply change the region or marker colour.
Name | Description | Examples |
| Changes the colour of the selected region or marker. |
|
| Clears all highlighted entries from the map. |
|
| Gets the list of currently highlighted entries. |
|
When using the highlight event in your own custom elements, it would be important to also use the clearHighlighted
method when hovering out your custom elements, so that it doesn’t stay with that state.
Experimental Methods
The functions below are still experimental and might change in future versions.
Name | Description | Example |
| Get a list of markers of a given map by value of a specific parameter; | // get markers with value 100 |
| Get a list of regions of a given map by value of a specific parameter; | // get regions with value 100 |