Options
All
  • Public
  • Public/Protected
  • All
Menu

Module MouseOver

JMap.MouseOver

JMap provide a mecanism that is called MouseOver.

We can defined from JMap Admin a mouseover for a layer.

The mouseover is written in HTML, enriched with JMap specific function that are interpretated.

When we click on layers that have a mouseover defined, JMap display a popup on the map with the formatted content for each features.

This section provide methods permitting you to customize the mouseover.

Index

Functions

closePopup

  • closePopup(): void
  • JMap.MouseOver.closePopup

    Close the mouseover popup if it's visible on the map, else do nothing.

    example
    
    // close the mouseover popup if it's visible on the map.
    JMap.MouseOver.closePopup()

    Returns void

isPopupOpened

  • isPopupOpened(): boolean
  • JMap.MouseOver.isPopupOpened

    Returns true if the mouseover popup is visible on the map, else false.

    example
    
    // returns true if the mouseover popup is visible on the map
    JMap.MouseOver.openPopup()

    Returns boolean

openInformationReportInNewTab

  • openInformationReportInNewTab(layerId: JId): Promise<string>
  • JMap.MouseOver.openInformationReportInNewTab

    Open the information report related to given layerId in a new tab.

    Display information report for all features that are displayed in the mouseover.

    throws

    if mouseover doesn't display any feature for the given layer

    example
    
    // open the information report related to layer id=3
    JMap.MouseOver.openInformationReportInNewTab(2)

    Parameters

    Returns Promise<string>

openPopup

  • JMap.MouseOver.openPopup

    Displays a given html content in a popup at a given location on the map

    example
    
    // open a popup at location lon=45.5 & lat=-73.5, that display the message "This is an example"
    JMap.MouseOver.openPopup({
     html: "<div style='margin-top: 1rem; background-color:#ff8888'>This is an example</div>",
     location: { y: 45.5, x:-73.5 }
    })

    Parameters

    Returns void

openPopupForSelection

  • JMap.MouseOver.openPopupForSelection

    Displays a standard MouseOver popup, based on a selection of features. You can specify an optional location to display the popup on the map, as well as an option to specify if the map shoud pan to the popup's location

    throws

    Error if the user-defined location is invalid or if the pan-to option is not a boolean

    example
    
    // display a MouseOver popup using the current selection and a custom location
    const currentSelection = JMap.Map.Selection.getSelectedFeatures()
    const myLocation = {x:-73, y:46}
    JMap.MouseOver.openPopupForSelection({ selection: currentSelection, location: myLocation, panToLocation: true })

    Parameters

    Returns void

renderForFeaturesAtLocation

  • renderForFeaturesAtLocation(containerId: string, location: JLocation): boolean
  • JMap.MouseOver.renderForFeaturesAtLocation

    Get the feature selection at the location, and process the mouseover for it, and render it inside the div of your choice.

    It's like clicking on the map at a location, but instead of displaying on a popup, you can render it on your own div.

    throws

    Error if div doesn't exist in the DOM, or location format is not good

    example
    
    // Display in the div id="my-custom-div" the content of mouseover
    // if features has been found at the location x=34.44 and y=23.44
    JMap.MouseOver.renderForFeaturesAtLocation("my-custom-div", { x: 34.44, y: 23.44 })

    Parameters

    • containerId: string

      The div id where to display the mouseover content

    • location: JLocation

      The location on the map where you want to select features and display mouseover for

    Returns boolean

    true if we displayed content in the div, false if no mouseover found for any layer

renderForFeaturesSelection

  • renderForFeaturesSelection(containerId: string, selection: JMapSelection): boolean
  • JMap.MouseOver.renderForFeaturesSelection

    From the feature selection you provide, it process the mouseover for it, and render it inside the div of your choice.

    throws

    Error if div doesn't exist in the DOM, or selection format is not good

    example
    
    // Display in the div id="my-custom-div" the content of mouseover for the provided selection
    JMap.MouseOver.renderForFeaturesSelection("my-custom-div", {
     4: [ // selection for layer 4
       { id: 345, type: "Point", geometry: {...}, properties: [...] },
       { id: 234, type: "Point", geometry: {...}, properties: [...] }
     ],
     8: [ // selection for layer 8
       { id: 187, type: "Line", geometry: {...}, properties: [...] },
       { id: 98, type: "Line", geometry: {...}, properties: [...] }
     ]
    })

    Parameters

    • containerId: string

      The div id where to display the mouseover content

    • selection: JMapSelection

      A feature selection, the mouseover will be processed only for this features

    Returns boolean

    true if we displayed content in the div, false if no mouseover found for any layer