map actions in leaflet

607
2
Jump to solution
03-26-2022 01:53 PM
BradSkopyk
New Contributor III

I would like to recreate the idea of 'map actions' within a leaflet environment, meaning that I would like a user to be able to click on text outside of the map div container and for that click to trigger a change in the map (the map focal point, zoom level, and the layers to be included). Is this possible? If so, can anyone point me in the direction of possible resources that would guild my steps? Many thanks.

0 Kudos
1 Solution

Accepted Solutions
GavinRehkemper
Esri Contributor

Hi BradSkopyk,

This is fairly easy to do. In your JavaScript code, you need to set up an event listener for when the button or link is clicked, you can run some code and do whatever you need to do with the Leaflet API or your Esri Leaflet objects. Here is an example: https://jsbin.com/pawuqut/2/edit?html,output

 

View solution in original post

2 Replies
GavinRehkemper
Esri Contributor

Hi BradSkopyk,

This is fairly easy to do. In your JavaScript code, you need to set up an event listener for when the button or link is clicked, you can run some code and do whatever you need to do with the Leaflet API or your Esri Leaflet objects. Here is an example: https://jsbin.com/pawuqut/2/edit?html,output

 

BradSkopyk
New Contributor III

This is very straightforward and exactly the solution I was looking for. Thank you! 

0 Kudos