Options
All
  • Public
  • Public/Protected
  • All
Menu

JMap.Event.MouseOver.on

Here you have all available user events on which you can attach a listener.

Index

Functions

afterContentProcessed

  • afterContentProcessed(listenerId: string, fn: function): void
  • JMap.Event.MouseOver.on.afterContentProcessed

    This event is triggered when the map has been clicked, after the mouseover content has been calculated.

    example
    
    // Each time map is clicked, and the mousover content has been calculated
    JMap.Event.MouseOver.on.afterContentProcessed("my-listener", params => {
      console.log("Mouseover content has been processed", params.content)
    })

    Parameters

    Returns void

beforeContentProcessed

  • beforeContentProcessed(listenerId: string, fn: function): void
  • JMap.Event.MouseOver.on.beforeContentProcessed

    This event is triggered each time the map is clicked, and before the mouseover content is calculated or popup opened.

    This event is a special on, as it offers 3 methods which can change the mouseover behavior:

    • getFeaturesByLayerId: it returns the feature that will be used to display the mouseover
    • addFeaturesToLayerSelection : add custom features to the mouseover
    • removeFeaturesFromLayerSelection: used to remove a clicked feature from the mouseover (will not be displayed in the mouseover)

    You can test the event function addFeaturesToLayerSelection, by pasting the following code in the console (adapt for your configuration):

    JMap.Event.MouseOver.on.beforeContentProcessed(
      "my-listener",
      params => {
        console.log("Mouseover selection before", params.selection[4])
        params.addFeaturesToLayerSelection(4, [{
          id: 58,
          properties: {JMAP_FID: 58, NOM_QR: "Bois-Francs"},
          type: "Feature",
          geometry: {coordinates: [],type: "Polygon"}
        }])
        console.log("Mouseover selection after", params.selection[4])
      }
    )

    This listener adds a feature on every click on the map, so no matter where you click, the mouseover will contains at least one feature (the one dynamically added by the listener)

    Then paste this in the console to remove the previous listener:

    JMap.Event.MouseOver.remove(“my-listener“)

    You can test that now no mouseover is displayed anymore when we click on an empty area.

    Finally you can test the event function removeFeaturesFromLayerSelection by pasting the following code snippet:

    JMap.Event.MouseOver.on.beforeContentProcessed(
      "my-listener",
      params => {
        console.log("Mouseover selection before", params.selection[4])
        params.removeFeaturesFromLayerSelection(4, [58])
        console.log("Mouseover selection after", params.selection[4])
      }
    )

    Now you can click on the feature id=58, but no mouseover will display for if, as it is automatically removed by the listener.

    example
    
    // Each time the map is clicked and "layer" interactor is active
    JMap.Event.MouseOver.on.beforeContentProcessed("my-listener", params => {
      // mouseover "clicked" features for layer id="3"
      let features = params.getFeaturesByLayerId(3) // returns an array copy
      // remove feature id=17
      params.removeFeaturesByLayerId(3, [123, 432])
      features = params.getFeaturesByLayerId(3)
      // now features id=123 and 432 are not anymore in features array
      const newFeature = { id="24553", ...etc } // a geojson feature
      params.addFeatureByLayerId(3, newFeature)
      features = params.getFeaturesByLayerId(3)
      // features contains the new feature and will display it in the mouseover
    })

    Parameters

    Returns void

popupClosed

  • popupClosed(listenerId: string, fn: function): void
  • JMap.Event.MouseOver.on.popupClosed

    This event is triggered when the popup has been closed.

    example
    
    // Each time the mouseover popup is hidden
    JMap.Event.MouseOver.on.popupClosed("my-listener", () => {
      console.log("Mouseover popup has been closed")
    })

    Parameters

    • listenerId: string

      Your listener id (must be unique for all mouseover events)

    • fn: function

      Your listener function

        • (): void
        • Returns void

    Returns void

popupOpened

  • popupOpened(listenerId: string, fn: function): void
  • JMap.Event.MouseOver.on.popupOpened

    This event is triggered when the popup has been opened.

    example
    
    // Each time the mouseover popup is displayed
    JMap.Event.MouseOver.on.popupOpened("my-listener", params => {
      console.log("Mouseover popup has been opened", params.content)
    })

    Parameters

    Returns void