API DOCUMENTATION

On
Adds a listener for events of a specified type occurring on features in a specified style layer.

map.on(type, layerId, listener)

Parameter

Parameter Description
type(string) The event type to listen for; one of 'mousedown' , 'mouseup' , 'click' , 'dblclick' , 'mousemove' , 'mouseenter' , 'mouseleave' , 'mouseover' , 'mouseout' , 'contextmenu' , 'touchstart' , 'touchend' , or 'touchcancel' . mouseenter and mouseover events are triggered when the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas. mouseleave and mouseout events are triggered when the cursor leaves a visible portion of the specified layer, or leaves the map canvas.
listener(Function) The function to be called when the event is fired.
layerld(string) (optional) The ID of a style layer. Only events whose location is within a visible feature in this layer will trigger the listener. The event will have a features property containing an array of the matching features.

[example : on]

map.on('click', function (e) {

    console.log('Click >>>>>>>',e)  //Map Click

})

  map.on('mouseover', 'fatosmarker', function (e) P

    if(e.originalEvent.toElement.id){  //marker mouseover

       console.log('Mouseover>>>>>>>',e)

    }

})