Azure maps close htmlMarker popup programmatically

Can’t seem to close the azure maps htmlMarker popup programmatically using popup.close()

I’m using azure maps to display htmlMarkers on the map and using azure maps htmlMarkers to display a popup when a marker is clicked. Azure maps htmlMarker popup provides a close button on the popup but I need the popup to close when a user clicks the Add to Route button on the popup. As per azure maps documentation popup.close should work but I can’t seem to make it work. Any suggestions will be greatly appreciated!

>Solution :

There are two ways to close the popup attached to an HTML marker programmatically.

The first, if you know it is open, is to use the markers togglePopup function.

 marker.togglePopup();

The second is to get the popup instance from the markers options, then call the close function.

marker.getOptions().popup.close();

Leave a Reply