Closing Azure.Atlas.popup('mouseleave')

Stephen Lau 21 Reputation points
2021-01-12T19:09:19.503+00:00

Hi All,

I have a question regarding 'mouseleave' event of an Atlas.Popup() that I hope someone has an answer to.

Everything is working the way I wanted, but with a slight issue. I have the following line and function added to my .js file

map.events.add("mouseleave", myLayer, closePopup);
and
closePopup: function () {
popup.close();
},

Problem is that my popup has a button that the user can click to run another process. By adding the code above, it's preventing me to click the button, as the popup close when I move slightly outside of the coordinates.

55824-popup-mouseleave.png

TIA,
Steve

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
736 questions
{count} votes

Accepted answer
  1. rbrundritt 18,681 Reputation points Microsoft Employee
    2021-01-13T02:12:08.243+00:00

    The will be difficult to achieve as the map is acting as it should. When the mouse is over the popup, it is no longer on the layer, thus the mouse leave event fires.

    A common workflow for this scenario is to show a preview when the user hovers. But when they click on the layer, have the popup stay open until they either click somewhere else on the map or press the close button of the popup. To achieve this you would need to do something like this:

    • Add mouse enter/leave and click events to layer. On enter, open popup. On leave, close popup. On close, remove enter/leave events, open popup.
    • When popup is closed after a click locked it open, re-add the mouse enter/leave events
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.