13
Views
4
Comments
Solved
[LeafletJS - Reactive] Leaflet polygon click event
Forge component by Vincent Koning
5
Published on 22 Jun 2020
Application Type
Reactive

I've got a Leaflet map that I am creating polygons, and I am trying to enable click events for them.

On the properties tab of the Leaflet element, in the Events section, I have identified a handler for the OnClick event, LeafletOnClick.  

I have specified MouseEvent (type is the Leaflet MouseEvent structure), as the handler for that event, (the input parameter of my LeafletOnClick action).  (My LeafletOnClick event for now is just coded to display a message that I have clicked the polygon).

The polygons are all created correctly, they all appear in their correct colors, positions, etc., and when I hover over one, the 'hand' icon changes to the 'pointing finger' icon, indicating it is recognizing the polygon element.

But when I click on it, it does not appear to fire the LeafletOnClick action.  I've even set a breakpoint inside the action, and it never hits it in debug mode, so it appears to not even register the click.

I've installed the Leaflet Demo, and it appears I'm doing everything that the marker click does in that demo (the demo does not have a polygon click).  Is there something I'm missing to get the LeafletOnClick to register when clicking one of the polygons?

123202023845PM.png

Rank: #3731
Solution

I've resolved the issue.  I have since found out that I needed to set the InitializeEvents.Click of my local variable holding the map markers to True.

Thanks.

Champion
Rank: #87

Hi Jeff,

I'll look into it. Do you happend to have a Proof of Concept demo that I can download and analyse? This will speed up the process. Please note that I'm swamped with work related issues at this moment so it can take some time.

Greetings,

Vincent

Rank: #3731
Solution

I've resolved the issue.  I have since found out that I needed to set the InitializeEvents.Click of my local variable holding the map markers to True.

Thanks.

Champion
Rank: #87

Hi Jeff,

Good to hear that your problem is solved. 

Greetings,

Vincent