Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Map

JMap.Map

This section contains map related methods.

Index

Modules

Functions

Functions

applyCurrentPixelRatio

  • applyCurrentPixelRatio(): Promise<void>
  • JMap.Map.applyCurrentPixelRatio

    Forces the map to redraw using the current device pixel ratio in usage.

    Rejects if the current device pixel ratio/map size combination is invalid .

    This is a technical method that you should never have to use.

    example
    
    JMap.Map.applyCurrentPixelRatio()
       .then(()=>console.log("Pixel ratio has been applied"))
       .catch(error=>console.log("An error occured while applying the pixel ratio:" , error))

    Returns Promise<void>

clearFlashingLocations

  • clearFlashingLocations(): void
  • JMap.Map.clearFlashingLocations

    Immediatly remove all flashed locations on the map that have been displayed using JMap.Map.flashLocation or JMap.Map.flashLocations

    example
    
    // flash a location indefinetly
    JMap.Map.flashLocation({x:-74.178, y:46.0455})
    
    // clear all flashed locations after a timeout of 30 seconds
    setTimeout(()=>JMap.Map.clearFlashingLocations(), 30000)

    Returns void

closeModificationPopup

  • closeModificationPopup(): void
  • JMap.Map.closeModificationPopup

    If opened, close the map change popup (for center/scale), else do nothing.

    example
    
    // if opened, closes the map change popup (for center/scale), else does nothing
    JMap.Map.closeModificationPopup()

    Returns void

displayExtent

  • JMap.Map.displayExtent

    Displays the given extent

    The extent will disappear after a few seconds

    example
    
    // Move to the extent of my boundary box and display it for a few second
    const myExtent = {sw: {x: -77,y: -37},ne: {x: 178,y: 58}}
    JMap.Map.displayExtent(myExtent, {moveToExtent: true})

    Parameters

    Returns void

displayLayerExtent

  • JMap.Map.displayLayerExtent

    Displays the layer extent of the given layer Id

    The layer extent will disappear after a few seconds

    example
    
    // Move to layer 4 extent and display it for a few second
    JMap.Map.displayLayerExtent(4, {moveToExtent: true})

    Parameters

    Returns Promise<boolean>

    A promise boolean that is true if the layer has an extent or false otherwise.

fitFeatures

  • JMap.Map.fitFeatures

    Move and zoom (or unzoom) to display the given features.

    throws

    Error if bad parameters are passed

    example
    
    // first select some features on layer id=3
    const features = JMap.Map.Selection.getSelectedFeaturesForLayer(3) // returns layer id=3 selected features
    // Move and zoom to display the features
    JMap.Map.fitFeatures(features)
    
    // The same with optional parameters
    JMap.Map.fitFeatures(features, {
     animate: false, // default true
     paddingTop: 120, // default 50
     paddingLeft: 100, // default 50
     paddingRight: 100, // default 50
     paddingBottom: 120, // default 50
     maxZoom: 10 // default the current zoom
    })

    Parameters

    • features: Feature[]

      The features where the map will be centered

    • Optional options: JPanAndZoomOptions

      parameter to customize the animation, padding, and/or maxZoomLevel

    Returns void

flashLocation

  • JMap.Map.flashLocation

    Display a pulsing dot on the map to hilite a location, with options

    Flashed feature can be immediatly removed using JMap.Map.clearFlashingLocations

    example
    
    // define a location in lat-lon coordinates
    const locationToFlash = {x:-74.178, y:46.0455}
    // define options
    const flashOptions = { // Optional.
     dotColor: { // Optional. Default { red: 165, green: 165, blue: 255, alpha: 1 }
       red:100 , // 0-255
       green:100 , // 0-255
       blue:255 , // 0-255
       alpha: 1.0 // 0-1
    },
     haloColor: { // Optional. Default { red: 105, green: 105, blue: 255, alpha: 1 }
       red:0 ,  // 0-255
       reen:255 , // 0-255
       blue:100 , // 0-255
       alpha: 1 // 0-1
    },
     size: 100, // Optional, in pixels, default 100
     delay: 5000, // Optional, in milliseconds. default no expiration delay (flash indefinitely)
     fitFeatures: true, // Optional, will pan and zoom to display all flashed features. Default: false
     panAndZoomOptions: { // optionnal
       animate: false, // default true
       paddingTop: 120, // default 50
       paddingLeft: 100, // default 50
       paddingRight: 100, // default 50
       paddingBottom: 120, // default 50
       maxZoom: 10 // default the current zoom
     }
    }
    
    JMap.Map.flashLocation(locationToFlash,flashOptions)

    Parameters

    Returns void

flashLocations

  • JMap.Map.flashLocations

    Display a collection of pulsing dots on the map to hilite several locations, with options

    Flashed features can be immediatly removed using JMap.Map.clearFlashingLocations

    example
    
    // define locations in lat-lon coordinates
    const locationsToFlash = [{x:-74.178, y:46.0455}, {x:-74.3, y:46.2}, {x:-74, y:46.2}]
    // define options
    const flashOptions = { // Optional.
     dotColor: { // Optional. Default { red: 165, green: 165, blue: 255, alpha: 1 }
       red:100 , // 0-255
       green:100 , // 0-255
       blue:255 , // 0-255
       alpha: 1.0 // 0-1
    },
     haloColor: { // Optional. Default { red: 105, green: 105, blue: 255, alpha: 1 }
       red:0 ,  // 0-255
       reen:255 , // 0-255
       blue:100 , // 0-255
       alpha: 1 // 0-1
    },
     size: 100, // Optional, in pixels, default 100
     delay: 5000, // Optional, in milliseconds. default no expiration delay (flash indefinitely)
     fitFeatures: true, // Optional, will pan and zoom to display all flashed features. Default: false
     panAndZoomOptions: { // optionnal
       animate: false, // default true
       paddingTop: 120, // default 50
       paddingLeft: 100, // default 50
       paddingRight: 100, // default 50
       paddingBottom: 120, // default 50
       maxZoom: 10 // default the current zoom
     }
    }
    
    JMap.Map.flashLocations(locationsToFlash,flashOptions)

    Parameters

    Returns void

getAllDistanceUnits

  • JMap.Map.getAllDistanceUnits

    Returns a list of all available distance units.

    example
    
    // returns list of all distance units
    // ["millimeters", "centimeters", "meters", "kilometers", "inches", "feet", "yards", "miles", "nauticalmiles" ]
    JMap.Map.getAllDistanceUnits()

    Returns JMAP_DISTANCE_UNITS[]

getBearing

  • getBearing(): number
  • JMap.Map.getBearing

    Returns the current map bearing angle.

    example
    
    // returns the current map bearing
    JMap.Map.getBearing()

    Returns number

getCenter

  • JMap.Map.getCenter

    Returns the location that is the current center of the map.

    example
    
    // returns the current center of the map
    JMap.Map.getCenter()

    Returns JLocation

getDistanceUnit

  • JMap.Map.getDistanceUnit

    Get the map defined distance unit.

    If no distance unit has been set by user, it returns the project distance unit, if no distance unit is set on the project, it returns "meters" by default.

    throws

    if no project is loaded

    example
    
    // returns undefined if no distance unit, else the value
    JMap.Map.getDistanceUnit()

    Returns JMAP_DISTANCE_UNITS

getDomContainerId

  • getDomContainerId(): string
  • JMap.Map.getDomContainerId

    Returns the map div container id, where the map is or will be created.

    example
    
    // returns the map div container id
    JMap.Map.getDomContainerId()

    Returns string

getExtent

  • JMap.Map.getExtent

    Returns the current map extent.

    example
    
    // returns the current map extent
    JMap.Map.getExtent()

    Returns JBoundaryBox

getLayersVisibilityStatus

  • JMap.Map.getLayersVisibilityStatus

    Returns layers visibility status.

    The result is a map (= javascript object) where :

    • the key is the JMap layer id
    • the value is a JMapLayersVisibilityStatus object

    A JMapLayersVisibilityStatus object has the following properties :

    • layerId: the layer id
    • layerName: the layer name
    • isRendered: true if 'visibilityProperty', 'parentVisibility',
              'scaleVisibility' and 'extentVisibility' are all true
    • visibilityProperty: user can show or hide a layer
    • parentVisibility: returns false if one of its group parent(s) has
                    its visibility property equals to false
    • scaleVisibility: returns false if at the current scale the layer
                   cannot be displayed
    • extentVisibility: returns false if the extent of the layer is not
                    contains by the current view of the map
    example
    
    // returns the visibility status
    JMap.Map.getLayersVisibilityStatus()
    
    // Example of result :
    {
     1: { layerId: 1, layerName: "layer 1", isRendered: true, visibilityProperty: true, parentVisibility: true, scaleVisibility: true, extentVisibility: true }
     2: { layerId: 2, layerName: "layer 2", isRendered: false, visibilityProperty: true, parentVisibility: true, scaleVisibility: false, extentVisibility: true }
     3: { layerId: 3, layerName: "layer 3", isRendered: false, visibilityProperty: false, parentVisibility: true, scaleVisibility: false, extentVisibility: true }
     4: { layerId: 4, layerName: "layer 4", isRendered: false, visibilityProperty: false, parentVisibility: false, scaleVisibility: false, extentVisibility: true }
     5: { layerId: 5, layerName: "layer 5", isRendered: false, visibilityProperty: true, parentVisibility: true, scaleVisibility: true, extentVisibility: false }
    }

    Returns JMapLayersVisibilityStatus

getLayersVisibilityStatusAsArray

  • JMap.Map.getLayersVisibilityStatusAsArray

    Returns layers visibility status as an array of JMapLayersVisibilityStatus object.

    A JMapLayersVisibilityStatus object has the following properties :

    • layerId: the layer id
    • layerName: the layer name
    • isRendered: true if 'visibilityProperty', 'parentVisibility',
              'scaleVisibility' and 'extentVisibility' are all true
    • visibilityProperty: user can show or hide a layer
    • parentVisibility: returns false if one of its group parent(s) has
                    its visibility property equals to false
    • scaleVisibility: returns false if at the current scale the layer
                   cannot be displayed
    • extentVisibility: returns false if the extent of the layer is not
                    contains by the current view of the map
    example
    
    // returns the visibility status as an object array
    JMap.Map.getLayersVisibilityStatusAsArray()
    
    // Example of result :
    [
     { layerId: 1, layerName: "layer 1", isRendered: true, visibilityProperty: true, parentVisibility: true, scaleVisibility: true, extentVisibility: true }
     { layerId: 2, layerName: "layer 2", isRendered: false, visibilityProperty: true, parentVisibility: true, scaleVisibility: false, extentVisibility: true }
     { layerId: 3, layerName: "layer 3", isRendered: false, visibilityProperty: false, parentVisibility: true, scaleVisibility: false, extentVisibility: true }
     { layerId: 4, layerName: "layer 4", isRendered: false, visibilityProperty: false, parentVisibility: false, scaleVisibility: false, extentVisibility: true }
     { layerId: 5, layerName: "layer 5", isRendered: false, visibilityProperty: true, parentVisibility: true, scaleVisibility: true, extentVisibility: false }
    ]

    Returns JMapLayerVisibilityStatus[]

getMap

  • getMap(): Map
  • JMap.Map.getMap

    Returns the Mapbox map instance, a MapBox map.

    example
    
    // returns the Mapbox map instance
    JMap.Map.getMap()

    Returns Map

getMapBoxSourceIdByJMapLayerId

  • getMapBoxSourceIdByJMapLayerId(layerId: JId): string
  • JMap.Map.getMapBoxSourceIdByJMapLayerId

    Returns the source id of the given Jmap layer id.

    throws

    if invalid JMap layer id or if JMap layer doesn't exist

    example
    
    // returns the source id of the JMap layer with id 4
    JMap.Map.getMapBoxSourceIdByJMapLayerId(4)

    Parameters

    • layerId: JId

      the JMap layer id

    Returns string

getMapJSLib

  • getMapJSLib(): any
  • JMap.Map.getMapJSLib

    Returns the MapBox JS library used to create the map.

    Useful to be able to create a map library object, by example a popup.

    example
    
    // Create a MapBox popup
    const myCustomPopup = JMap.Map.getMapJSLib().Popup({
      closeButton: false,
      closeOnClick: false
    })

    Returns any

getMapboxSupportedJMapLayerAfter

  • getMapboxSupportedJMapLayerAfter(layerId: JId): JId | undefined
  • JMap.Map.getMapboxSupportedJMapLayerAfter

    Returns the Mapbox supported JMap layer id that is ordered after the JMap layer id provided in argument.

    throws

    Error if layer is not found

    example
    
    // Returns the layer id that is located after layer id=3
    JMap.Map.getMapboxSupportedJMapLayerAfter(3)

    Parameters

    • layerId: JId

      The JMap layer id

    Returns JId | undefined

    the JMap layer id, or undefined if no layer after

getMapboxSupportedJMapLayerBefore

  • getMapboxSupportedJMapLayerBefore(layerId: JId): JId | undefined
  • JMap.Map.getMapboxSupportedJMapLayerBefore

    Returns the Mapbox supported JMap layer id that is ordered before the JMap layer id provided in argument.

    throws

    Error if layer is not found

    example
    
    // Returns the layer id that is located before layer id=4
    JMap.Map.getMapboxSupportedJMapLayerBefore(4)

    Parameters

    • layerId: JId

      The JMap layer id

    Returns JId | undefined

    the JMap layer id, or undefined if no layer before

getMapboxSupportedJMapLayerIds

  • getMapboxSupportedJMapLayerIds(): JId[]
  • JMap.Map.getMapboxSupportedJMapLayerIds

    Returns all layer ids that are displayed by the map.

    Mapbox doesn't support all layer types defined in JMap Server.

    This function returns all layers ids that are managed by the map.

    example
    
    // returns layer ids supported by the Mapbox
    JMap.Map.getMapboxSupportedJMapLayerIds()

    Returns JId[]

getMouseCursor

  • getMouseCursor(): string
  • JMap.Map.getMouseCursor

    Returns the current map mouse cursor.

    throws

    if the map is not ready

    example
    
    // returns the current map mouse cursor
    JMap.Map.getMouseCursor()

    Returns string

getNavigationHistoryStack

  • JMap.Map.getNavigationHistoryStack

    Returns the complete stack of navigation steps recorded in the session (stack is limited to 64 entries, older ones are discarded)

    example
    
    // get the navigation stack
    const navStack: JMapNavigationStep[] = JMap.Map.getNavigationHistoryStack()

    Returns JMapNavigationStep[]

    an array of JMapNavigationStep

getPitch

  • getPitch(): number
  • JMap.Map.getBaseMap

    Returns the current map pitch.

    example
    
    // returns the current map pitch
    JMap.Map.getPitch()

    Returns number

getRasterLayerInitialTransparency

  • getRasterLayerInitialTransparency(layerId: JId): number
  • JMap.Map.getRasterLayerInitialTransparency

    Return the initial transparency (defined on the layer style) for a given raster layer

    throws

    Error if layer not found or not a raster layer

    example
    
     // returns the initial transparency of raster layer id=4
     JMap.Map.getRasterLayerInitialTransparency(4)

    Parameters

    • layerId: JId

      The JMap layer id

    Returns number

    the initial transparency value

getRasterLayerTransparency

  • getRasterLayerTransparency(layerId: JId): number
  • JMap.Map.getRasterLayerTransparency

    Returns the transparency for a given raster layer

    throws

    Error if layer not found or not a raster layer

    example
    
     // returns the transparency of raster layer id=4
     JMap.Map.getRasterLayerTransparency(4)

    Parameters

    • layerId: JId

      The JMap layer id

    Returns number

    the current transparency value

getRenderedFeatures

  • JMap.Map.getRenderedFeatures

    Returns rendered geojson features for the specified Jmap layer. Features that are not rendered (i.e. filtered by MapBox) are not returned

    If the JMap layer is not visible, no features are returned.

    MapBox splits geometries along tiles internally, meaning for instance that a polygon feature that crosses many tiles will be returned as multiple polygon pieces (sharing all properties of the original source features). By default, getRenderedFeatures will only return one of those pieces (a random one). If you pass a JGetRenderedFeaturesParams with keepAllTiles = true, all feature pieces will be returned by getRenderedFeatures.

    throws

    Error if layer is not found

    throws

    Error if no or incorrect filter is passed

    example
    
    // Returns all rendered geojson features for layer 4
    JMap.Map.getRenderedFeatures(4)
    
    // Returns all rendered geojson features for layer 4 at location x=45.54 and y=65.43
    JMap.Map.getRenderedFeatures(4, { x: 45.54, y: 65.43 })
    
    // Returns all rendered geojson features for layer 4, that intersect the circle (radius in km)
    JMap.Map.getRenderedFeatures(4, { center: { x: 45.54, y: 65.43 }, radius: .5 })
    
    // Returns all rendered geojson features for layer 4, that intersect the boundary box
    // having south-west { x=45.54 and y=65.43 } and north-est { x=48.54 and y=70.43 }
    JMap.Map.getRenderedFeatures(4, {
     sw: { x: 45.54, y: 65.43 },
     ne: { x: 48.54, y: 70.43 }
    })
    
    // Returns all rendered geojson features for layer 4 that intersect a circle (radius in km), without any mapbox filter
    JMap.Map.getRenderedFeatures(4, {filter: { center: { x: 45.54, y: 65.43 }, radius: .5 }, ignoreMapBoxFilter: true})

    Parameters

    Returns Feature[]

    A features array

getRenderedFeaturesAttributeValues

  • JMap.Map.getRenderedFeaturesAttributeValues

    Returns rendered features attributes for the layer.

    The result is an array of object, one object for each feature. Each object contains all feature's attributes, plus another one that is called "featureId" and contains the feature id.

    throws

    Error if layer is not found

    throws

    Error if no or incorrect filter is passed

    example
    
    // returns all features attributes for layer 4
    JMap.Map.getRenderedFeaturesAttributeValues(4)
    
    // returns all features attributes for layer 4, that intersect the location
    JMap.Map.getRenderedFeaturesAttributeValues(4, { x: 45.54, y: 65.43 })
    
    // returns all features attributes for layer 4, that intersect the circle (radius in km)
    JMap.Map.getRenderedFeaturesAttributeValues(4, { center: { x: 45.54, y: 65.43 }, radius: .5 })
    
    // returns all features attributes for layer 4, that intersect the boundary box
    JMap.Map.getRenderedFeaturesAttributeValues(4, { sw: { x: 45.54, y: 65.43 }, ne: { x: 48.54, y: 70.43 }})
    
    // Example of result for features that have only 2 attributes "Firestation" and "Nursery" :
    [
     { name: "Firestation", age: 23, featureId: 2377 },
     { name: "Nursery", age: 20, featureId: 3456 }
    ]

    Parameters

    • layerId: JId

      The JMap layer id

    • Optional filter: JLocation | JBoundaryBox | JCircle

      You can pass a location, a boundary box, or a circle (radius in km). Will returns only features that intersect.

    Returns JMapFeatureAttributeValues[]

    An object array

getRenderedJMapLayerIds

  • getRenderedJMapLayerIds(): JId[]
  • JMap.Map.getRenderedJMapLayerIds

    Returns the ids of the layers that are displayed on the map.

    Mapbox doesn't support all layer types defined on JMap Server.

    This function returns all layers ids that are managed by the map.

    example
    
    // returns all layer ids that are managed by the map
    JMap.Map.getRenderedJMapLayerIds()

    Returns JId[]

getResolution

  • JMap.Map.getResolution

    Returns the screen resolution, depending on screen DPI, latitude, and zoom level.

    if params is passed will use the given values for latitude (center of the map) and zoom, else use map current ones.

    Note: screen DPI is fixed.

    example
    
    // returns the current resolution for current map latitude (center of the map) and zoom level
    JMap.Map.getResolution()
    
    // returns the resolution for given map latitude=45.5 and zoom level = 4
    JMap.Map.getResolution({
      latitude: 45.5,
      zoom: 4
    })

    Parameters

    • Optional params: JLatitudeAndZoom

      if passed will use the given values for latitude and zoom, else use map current values

    Returns number

getRotation

  • getRotation(): number
  • JMap.Map.getRotation

    Returns the current map rotation angle.

    example
    
    // returns the current map rotation
    JMap.Map.getRotation()

    Returns number

getScale

  • JMap.Map.getScale

    Returns the map scale, depending on screen DPI, latitude, and zoom level.

    if params is passed will use the given values for latitude (center of the map) and zoom, else use map current ones.

    Note: screen DPI is fixed.

    example
    
    // returns the current map scale
    // for instance : "1 : 12959346"
    JMap.Map.getScale()
    
    // returns the map scale for given map latitude=45.5 and zoom level = 4
    // for instance: "1 : 12959346"
    JMap.Map.getScale({
      latitude: 45.5,
      zoom: 4
    })

    Parameters

    • Optional params: JLatitudeAndZoom

      if passed will use the given values for latitude and zoom, else use map current values

    Returns string

getScaleControlPosition

  • JMap.Map.getScaleControlPosition

    Returns the current scale control position on the map.

    example
    
    // Returns the current scale control position
    JMap.Map.getScaleControlPosition()

    Returns JMAP_POSITIONS

getScaleDenominator

  • JMap.Map.getScaleDenominator

    Returns the map scale denominator, depending on screen DPI, latitude, and zoom level.

    For instance if the scale is "1 : 12959346", the denominator is the number 12959346.

    if params is passed will use the given values for latitude (center of the map) and zoom, else use map current ones.

    Note: screen DPI is fixed.

    example
    
    // returns the current map scale
    JMap.Map.getScaleDenominator()
    
    // returns the map scale for given map latitude=45.5 and zoom level = 4
    JMap.Map.getScaleDenominator({
      latitude: 45.5,
      zoom: 4
    })

    Parameters

    • Optional params: JLatitudeAndZoom

      if passed will use the given values for latitude and zoom, else use map current values

    Returns number

getSourceFeatures

  • JMap.Map.getSourceFeatures

    Returns geojson features for the specified JMap layer whether or not they are currently rendered by MapBox (i.e. whether or not they are filtered on screen)

    If the JMap layer is not visible, no features are returned.

    MapBox splits geometries along tiles internally, meaning for instance that a polygon feature that crosses many tiles will be returned as multiple polygon pieces (sharing all properties of the original source features). By default, getSourceFeatures will only return one of those pieces (a random one). If you pass a JGetSourceFeaturesParams with keepAllTiles = true, all feature pieces will be returned by getSourceFeatures. If you pass a JGetSourceFeaturesParams with keepAllTiles = false (or if keepAllTiles is not specified), and if a viewport is specified in the JGetSourceFeaturesParams, the sole feature piece returned is garanteed to be included in the viewport.

    throws

    Error if layer is not found

    throws

    Error any invalid parameter is passed

    example
    
    const viewPort = JMap.Geometry.getPolygonFeature({
       type: "Polygon",
       coordinates: [
         [
           [ 20.44, 10.32 ],
           [ 20.44, 78.44 ],
           [ 40.56, 78.44 ],
           [ 40.56, 10.32 ],
           [ 20.44, 10.32 ]
         ]
       ]
    })
    
    const features = JMap.Map.getSourceFeatures(1, {viewport: viewport})
    console.log("features for layer id=1 :" , features)
    

    Parameters

    Returns Feature[]

getZoom

  • getZoom(): number
  • JMap.Map.getZoom

    Returns the current map zoom.

    example
    
    // returns the current map zoom
    JMap.Map.getZoom()

    Returns number

getZoomFromScale

  • getZoomFromScale(scaleDenominator: number, latitude?: undefined | number): number
  • JMap.Map.getZoomFromScale

    returns the zoom corresponding to the given scale.

    example
    
    // returns the corresponding zoom level for the given scale 2344
    JMap.Map.getZoomFromScale(2344)

    Parameters

    • scaleDenominator: number

      must be greater than 0

    • Optional latitude: undefined | number

      must be greater than 0

    Returns number

isLayerRendered

  • isLayerRendered(layerId: JId): boolean
  • JMap.Map.isLayerRendered

    Returns true if layer is visible on the map.

    To be true the layer visibility property has to be true, and the current map scale between the layer min and max scale.

    example
    
    // returns true if layer is visible on the map
    JMap.Map.isLayerRendered(4)

    Parameters

    Returns boolean

isMapCreated

  • isMapCreated(): boolean
  • JMap.Map.isMapCreated

    Returns true if the map has been created.

    example
    
    // returns true or false
    JMap.Map.isMapCreated()

    Returns boolean

isMapInfoControlExpanded

  • isMapInfoControlExpanded(): boolean
  • JMap.Map.isMapInfoControlExpanded

    Returns true if the Map Info control is expanded.

    example
    
    // returns true if control is expanded
    JMap.Map.isMapInfoControlExpanded()

    Returns boolean

isMapInfoControlVisible

  • isMapInfoControlVisible(): boolean
  • JMap.Map.isMapInfoControlVisible

    Returns true if the Map Info control is visible on the map.

    example
    
    // returns true if control is displayed on the map
    JMap.Map.isMapInfoControlVisible()

    Returns boolean

isMapLoaded

  • isMapLoaded(): boolean
  • JMap.Map.isMapLoaded

    Returns true if the map has been loaded and is ready.

    example
    
    // returns true or false
    JMap.Map.isMapLoaded()

    Returns boolean

isMapRotationControlVisible

  • isMapRotationControlVisible(): boolean
  • JMap.Map.isMapRotationControlVisible

    Returns true if the Map Rotation control is visible on the map.

    example
    
    // returns true if control is displayed on the map
    JMap.Map.isMapRotationControlVisible()

    Returns boolean

isNavigationHistoryControlVisible

  • isNavigationHistoryControlVisible(): boolean
  • JMap.Map.isNavigationHistoryControlVisible

    Returns true if the Navigation History control is visible on the map.

    example
    
    // returns true if control is displayed on the map
    JMap.Map.isNavigationHistoryControlVisible()

    Returns boolean

isPixelRatioCurrentlyValid

  • isPixelRatioCurrentlyValid(pixelRatio: number): boolean
  • JMap.Map.isPixelRatioCurrentlyValid

    Returns true if the pixel ratio/map size combination is currently valid, false otherwise.

    throws

    Error if pixelRatio is not a number

    example
    
    JMap.Map.isPixelRatioCurrentlyValid(2)
    // true
    JMap.Map.isPixelRatioCurrentlyValid(9999)
    // false

    Parameters

    • pixelRatio: number

      The pixel ratio to test

    Returns boolean

isScaleControlVisible

  • isScaleControlVisible(): boolean
  • JMap.Map.isScaleControlVisible

    Returns true if the scale control panel is visible on the map.

    example
    
    // returns true if control is displayed on the map
    JMap.Map.isScaleControlVisible()

    Returns boolean

navigateTo

  • JMap.Map.navigateTo

    Navigate to a location on the map (animated)

    example
    
    // Navigate to a location on the map
    JMap.Map.navigateTo({center: { x: 45.34, y: 65.87 }, zoom: 5, bearing: 170, pitch: 30, mapBoxEventData: { stopJMapEventPropagation: true }})

    Parameters

    Returns void

openModificationPopupForCenter

  • openModificationPopupForCenter(): void
  • JMap.Map.openModificationPopupForCenter

    Opens a popup in order to change the current map center.

    example
    
    // opens a popup in order to change the current map center.
    JMap.Map.openModificationPopupForCenter()

    Returns void

openModificationPopupForScale

  • openModificationPopupForScale(): void
  • JMap.Map.openModificationPopupForScale

    Opens a popup in order to change the current map scale.

    example
    
    // opens a popup in order to change the current map scale.
    JMap.Map.openModificationPopupForScale()

    Returns void

panAndZoomTo

  • JMap.Map.panAndZoomTo

    Move and zoom (or unzoom) the map (animated)

    throws

    Error if bad parameters are passed

    example
    
    // Move and zoom the map
    JMap.Map.panAndZoomTo({ x: 45.34, y: 65.87 }, 5)

    Parameters

    • center: JLocation

      The location where the map will be centered

    • zoom: number

      The zoom level to apply

    • Optional options: JPanAndZoomOptions

      animation, zoom padding, stop event, etc ...

    Returns void

panTo

  • panTo(center: JLocation, stopJMapEventPropagation?: undefined | false | true): void
  • JMap.Map.panTo

    Move and center the map to the location (animated)

    throws

    Error if no or incorrect center is passed

    example
    
    // Move the map to the desired location
    JMap.Map.panTo({ x: 45.34, y: 65.87 })

    Parameters

    • center: JLocation

      The location where the map will be centered

    • Optional stopJMapEventPropagation: undefined | false | true

      if true will prevent JMap events to be fired

    Returns void

refreshLayerById

  • refreshLayerById(layerId: JId): void
  • JMap.Map.refreshLayerById

    This method only works with vector layers that are not served via vector tiles

    Refreshes the specified layer data on the Map. Can be called for instance after a feature has been added, deleted, or modified in the layer content server-side

    throws

    Error if layer is not found

    example
    
    // Refreshes layer id 4 on the map
    JMap.Map.refreshLayerById(4)

    Parameters

    • layerId: JId

      The JMap layer id

    Returns void

resetRasterLayerTransparency

  • resetRasterLayerTransparency(layerId: JId): number
  • JMap.Map.resetRasterLayerTransparency

    Resets the raster layer transparency to its initial value as defined on the server

    throws

    Error if layer is not found or not a raster layer

    example
    
    // Make raster layer id=3 transparent
    JMap.Map.setRasterLayerTransparency(10, 1)
    // Reset to its initial opacity
    JMap.Map.resetRasterLayerTransparency(3)

    Parameters

    • layerId: JId

      The JMap layer id

    Returns number

    the initial transparency value

setBearing

  • setBearing(bearing: number): void
  • JMap.Map.setBearing

    Set the bearing on the map.

    throws

    Error if the bearing angle is not between -360 to 360 degree

    example
    
    // Set 30 degrees bearing
    JMap.Map.setBearing(30)

    Parameters

    • bearing: number

      the new degree of the bearing between -360 to 360

    Returns void

setDefaultZoomOptions

  • setDefaultZoomOptions(options?: Partial<JZoomOptions>): void
  • JMap.Map.setDefaultZoomOptions

    Set zoom default values in JMap Core.

    This default values will be used in all methods that use zoom options.

    If zoom options are passed in methods, this default values will be overriden by passed values.

    If no object is passed, default values are reset with JMap Core default values.

    example
    
    // Set default values used by JMap Core
    JMap.Map.setDefaultZoomOptions({
     animate: false,
     paddingTop: 20,
     paddingLeft: 20,
     paddingRight: 20,
     paddingBottom: 20
    })
    
    // Reset default values with JMap Core default values
    // animate=true, and paddings are all 50.
    JMap.Map.setDefaultZoomOptions()

    Parameters

    • Optional options: Partial<JZoomOptions>

      animation, paddings, and maxZoom

    Returns void

setDistanceUnit

  • JMap.Map.setDistanceUnit

    Set the distance unit, for the current project.

    Save this preference in local storage.

    throws

    if bad distance unit is provided, or no project is loaded

    example
    
    // Set the distance unit to "miles"
    JMap.Map.setDistanceUnit("miles")

    Parameters

    Returns void

setMapInfoControlExpansion

  • setMapInfoControlExpansion(isExpanded: boolean): void
  • JMap.Map.setMapInfoControlExpansion

    Changes the Map Info control visibility on the map.

    example
    
    // expands the Map Info control
    JMap.Map.setMapInfoControlExpansion(true)
    
    // minimises the Map Info control
    JMap.Map.setMapInfoControlExpansion(false)

    Parameters

    • isExpanded: boolean

      true to expand the control, false to minimise

    Returns void

setMapInfoControlVisibility

  • setMapInfoControlVisibility(isVisible: boolean): void
  • JMap.Map.setMapInfoControlVisibility

    Changes the Map Info control visibility on the map.

    example
    
    // displays the Map Info control on the map
    JMap.Map.setMapInfoControlVisibility(true)
    
    // hides the Map Info control on the map
    JMap.Map.setMapInfoControlVisibility(false)

    Parameters

    • isVisible: boolean

      true to display the Map Info control, false to hide

    Returns void

setMapRotationControlVisibility

  • setMapRotationControlVisibility(isVisible: boolean): void
  • JMap.Map.setMapRotationControlVisibility

    Changes the Map Rotation control visibility on the map.

    example
    
    // displays the Map Rotation control on the map
    JMap.Map.setMapRotationControlVisibility(true)
    
    // hides the Map Rotation control on the map
    JMap.Map.setMapRotationControlVisibility(false)

    Parameters

    • isVisible: boolean

      true to display the Map Rotation control, false to hide

    Returns void

setMouseCursor

  • setMouseCursor(cursor: string): void
  • JMap.Map.setMouseCursor

    Set the map mouse cursor.

    If cursor is an empty string will unset the cursor (the mapbox default will be used).

    throws

    if the map is not ready

    example
    
    // set the map mouse cursor as "move"
    JMap.Map.setMouseCursor("move")
    
    // set the map mouse cursor as "default"
    JMap.Map.setMouseCursor("default")
    
    // unset map mouse cursor (a hand will be displayed)
    JMap.Map.setMouseCursor("")

    Parameters

    • cursor: string

      the mouse cursor

    Returns void

setNavigationHistoryControlVisibility

  • setNavigationHistoryControlVisibility(isVisible: boolean): void
  • JMap.Map.setNavigationHistoryControlVisibility

    Changes the Navigation History control visibility on the map.

    example
    
    // displays the Navigation History control on the map
    JMap.Map.setNavigationHistoryControlVisibility(true)
    
    // hides the Navigation History control on the map
    JMap.Map.setNavigationHistoryControlVisibility(false)

    Parameters

    • isVisible: boolean

      true to display the Navigation History control, false to hide

    Returns void

setPitch

  • setPitch(pitch: number): void
  • JMap.Map.setPitch

    Set the pitch on the map

    throws

    Error if the pitch is not between 0 to 60 degree

    example
    
    // Set 30 degrees pitch
    JMap.Map.setPitch(30)

    Parameters

    • pitch: number

      te new value of the pitch between 0 to 60

    Returns void

setRasterLayerTransparency

  • setRasterLayerTransparency(layerId: JId, transparency: number): void
  • JMap.Map.setRasterLayerTransparency

    Sets the transparency for a given raster layer

    throws

    Error if layer is not found, not a raster layer or transparency is invalid

    example
    
    // Make raster layer id=10 transparent
    JMap.Map.setRasterLayerTransparency(10, 1)

    Parameters

    • layerId: JId

      The JMap layer id

    • transparency: number

      the new layer transparency between 0 and 1

    Returns void

setRotation

  • setRotation(rotation: number): void
  • JMap.Map.setRotation

    Set the rotation on the map.

    throws

    Error if the rotation angle is not between -360 to 360 degree

    example
    
    // Set 30 degrees rotation
    JMap.Map.setRotation(30)

    Parameters

    • rotation: number

      the new degree of the rotation between -360 to 360

    Returns void

setScale

  • JMap.Map.setScale

    Zooms or unzooms the map to reach the given map scale

    example
    
    // zooms or unzooms the map to reach the given map scale
    JMap.Map.setScale(2344, { animate: true })

    Parameters

    • scaleDenominator: number

      must be greater than 0

    • Optional options: JPanAndZoomOptions

      animation, zoom padding, stop event, etc ...

    Returns number

setScaleControlPosition

  • JMap.Map.setScaleControlPosition

    Changes the scale control position on the map.

    example
    
    // Moves the scale control on the top-left corner of the map
    JMap.Map.setScaleControlPosition("top-left")

    Parameters

    • position: JMAP_POSITIONS

      the position on the map where to display the scale control.

    Returns void

setScaleControlUnits

  • setScaleControlUnits(units: "imperial" | "metric" | "nautical"): void
  • JMap.Map.setScaleControlUnits

    Changes the scale control units.

    example
    
    // Changes the scale control for imperial units
    JMap.Map.setScaleControlUnits("imperial")

    Parameters

    • units: "imperial" | "metric" | "nautical"

      possible values : "imperial", "metric", or "nautical"

    Returns void

setScaleControlVisibility

  • setScaleControlVisibility(isVisible: boolean, position?: JMAP_POSITIONS): void
  • JMap.Map.setScaleControlVisibility

    Changes the scale control panel visibility on the map.

    example
    
    // Displays the scale control on the map
    JMap.Map.setScaleControlVisibility(true)
    
    // Hides the scale control on the map
    JMap.Map.setScaleControlVisibility(false)

    Parameters

    • isVisible: boolean

      true to display the scale control, false to hide

    • Optional position: JMAP_POSITIONS

      the position on the map where to display the scale control.

    Returns void

undoLastNavigationStep

  • JMap.Map.undoLastNavigationStep

    Step back in the navigation history recorded in the current map session

    Will apply the necessary pan, zoom, bearing and pitch to get back to the last Map view. Maximum number of recorded steps is 64 (older steps get erased)

    example
    
    // navigate to the previous recorded map view
    const lastStep: JMapNavigationStep | undefined = JMap.Map.undoLastNavigationStep()

    Returns JMapNavigationStep | undefined

    The last JMapNavigationStep, or undefined if the stack is not rewindable anymore

zoomTo

  • JMap.Map.zoomTo

    Zoom or unzoom the map (animated)

    throws

    Error if no zoom is passed

    example
    
    // Zoom or unzoom the map to reach the desired zoom level
    JMap.Map.zoomTo(4.45)

    Parameters

    • zoom: number

      The zoom level to apply

    • Optional options: JPanAndZoomOptions

      animation, zoom padding, stop event, etc ...

    Returns void

zoomToRect

  • JMap.Map.zoomToRect

    Zoom or unzoom to fit exactly the boundary box (animated)

    throws

    Error if an invalid bbox is passed

    example
    
    // Zoom or unzoom to fit exactly the boundary box
    JMap.Map.zoomToRect({ sw: { x: 12, y: 34 }, ne: { x: 23, y: 32 }})

    Parameters

    Returns void