Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Measure

JMap.Application.Selection

You can manage the application measure tools here.

Index

Functions

activateMeasureType

  • JMap.Application.Measure.activateMeasureType

    Activates a measure type for the drawing measurement tool.

    example
    
    // change the measure type to length
    JMap.Application.Measure.activateMeasureType("length")

    Parameters

    Returns void

deleteAll

  • deleteAll(): number
  • JMap.Application.Measure.deleteAll

    Deletes all measures.

    Returns deleted measure count.

    example
    
    // delete all measures
    const deletedMeasuresCount = JMap.Application.Measure.deleteAll()

    Returns number

deleteAllCircles

  • deleteAllCircles(): number
  • JMap.Application.Measure.deleteAllCircles

    Deletes all measures having type === "circle".

    Returns deleted measure count.

    example
    
    // delete all circle measures (if exist)
    const deletedMeasuresCount = JMap.Application.Measure.deleteAllCircles()

    Returns number

deleteAllLines

  • deleteAllLines(): number
  • JMap.Application.Measure.deleteAllLines

    Deletes all measures having type === "line_string".

    Returns deleted measure count.

    example
    
    // delete all line measures (if exist)
    const deletedMeasuresCount = JMap.Application.Measure.deleteAllLines()

    Returns number

deleteAllPolygons

  • deleteAllPolygons(): number
  • JMap.Application.Measure.deleteAllPolygons

    Deletes all measures having type === "polygon".

    Returns deleted measure count.

    example
    
    // delete all polygon measures (if exist)
    const deletedMeasuresCount = JMap.Application.Measure.deleteAllPolygons()

    Returns number

deleteMeasuresById

  • deleteMeasuresById(measureIds: string[]): number
  • JMap.Application.Measure.deleteMeasuresById

    Deletes a measure for a given id.

    throws

    if measure is not found

    example
    
    // delete measure having id="bc4fc07f2e84eb50f5962d3d41c836cb"
    const deletedMeasuresCount = JMap.Application.Measure.deleteMeasuresById("bc4fc07f2e84eb50f5962d3d41c836cb")

    Parameters

    • measureIds: string[]

      list of measure ids

    Returns number

deleteSelected

  • deleteSelected(): number
  • JMap.Application.Measure.deleteSelected

    Deletes all selected measures.

    Returns deleted measure count.

    example
    
    // delete all selected measures
    const deletedMeasuresCount = JMap.Application.Measure.deleteSelected()

    Returns number

existsById

  • existsById(measureId: string): boolean
  • JMap.Application.Measure.existsById

    Returns true if a measure exists for the given id, else false.

    throws

    Error if measureId is not a string or an empty string

    example
    
    // return true if the measure exists, else false
    JMap.Application.Measure.existsById("ac57b1bd83ca6d8e0013e4cf9f06847e")
    
    // throws an error
    JMap.Application.Measure.existsById("")
    
    // throws an error
    JMap.Application.Measure.existsById()

    Parameters

    • measureId: string

    Returns boolean

getActiveMeasureType

  • JMap.Application.Measure.getActiveMeasureType

    Returns the current active measure type.

    example
    
    // return active mesure type
    JMap.Application.Measure.getActiveMeasureType([])

    Returns JAPP_MEASURE_TYPES

getAll

  • JMap.Application.Measure.getAll

    Returns all measures.

    example
    
    // return currently drawn measures
    JMap.Application.Measure.getAll()

    Returns JAppMeasure[]

getAllCircleMeasures

  • JMap.Application.Measure.getAllCircleMeasures

    Returns all "circle" measures. Result contains no line or polygon measures.

    example
    
    // return all circle measures
    JMap.Application.Measure.getAllCircleMeasures()

    Returns JAppMeasure[]

getAllLineMeasures

  • JMap.Application.Measure.getAllLineMeasures

    Returns all "line" measures. Result contains no polygon or circle measures.

    example
    
    // return all line measures
    JMap.Application.Measure.getAllLineMeasures()

    Returns JAppMeasure[]

getAllPolygonMeasures

  • JMap.Application.Measure.getAllPolygonMeasures

    Returns all "polygon" measures. Result contains no line or circle measures.

    example
    
    // return all polygon measures
    JMap.Application.Measure.getAllPolygonMeasures()

    Returns JAppMeasure[]

getById

  • JMap.Application.Measure.getById

    Returns the measure for the given id.

    throws

    Error if measureId is not a string or an empty string, or if measure is not found

    example
    
    // return the measure for the given id
    JMap.Application.Measure.getById("ac57b1bd83ca6d8e0013e4cf9f06847e")
    
    // throws an error
    JMap.Application.Measure.getById("")
    
    // throws an error
    JMap.Application.Measure.getById()

    Parameters

    • measureId: string

    Returns JAppMeasure

getMeasurementSystem

  • JMap.Application.Measure.getMeasurementSystem

    Returns the current measurement system used by the Measurements Panel

    example
    
    // get the current measurement system
    console.log(JMap.Application.Measure.getMeasurementSystem())
    // "geodetic"

    Returns JAPP_MEASUREMENT_SYSTEMS

getSelectedIds

  • getSelectedIds(): string[]
  • JMap.Application.Measure.getSelectedIds

    Returns the current measure selection.

    example
    
    // return current measure selection
    JMap.Application.Measure.getSelectedIds([])

    Returns string[]

setAllMeasures

  • JMap.Application.Measure.setAllMeasures

    Resets measures with provided measures.

    example
    
    // remove all measures
    JMap.Application.Measure.setAllMeasures([])

    Parameters

    Returns void

setMeasurementSystem

  • JMap.Application.Measure.setMeasurementSystem

    Sets the measurement system used by the Measurements Panel. This setting is only taken into account when you draw measurements using the Measurements Panel. It does not affect jmap-core-js methods like JMap.Geometry.getDistance, which always return geodetic values.

    This method should not be called in regular situations.

    Default measurement system is "geodetic", meaning that all measurements are representative of the length or area of features on the surface of the Earth. This is what is normally desired.

    In some rare situations, someone may want to get the length or area of measurements in the map's projection plane (EPSG:3857 - WGS 84 / Pseudo-Mercator). In this case, they can set the measurement system to "planar".

    Be warned that lengths or areas in planar context are not representative of the real dimensions on the earth's surface. The only supported planar projection for measurements is EPSG:3857.

    example
    
    // set the current measurement system to "geodetic"
    JMap.Application.Measure.setMeasurementSystem("geodetic")

    Parameters

    Returns void

setSelectionActive

  • setSelectionActive(isSelectionActive: boolean): void
  • JMap.Application.Measure.setSelectionActive

    Activates or deactivates the measurement selection mode.

    If active, measures can be selected by clicking on the map (then changed or removed).

    example
    
    // activate selection of measures
    JMap.Application.Measure.setSelectionActive(true)
    
    // deactivate selection of measure
    JMap.Application.Measure.setSelectionActive(false)

    Parameters

    • isSelectionActive: boolean

      true to activate selection mode, false to deactivate

    Returns void