Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Basemap

Index

Functions

activateById

  • activateById(basemapId: string): void
  • JMap.Map.Basemap.activateById

    Apply the basemap on the map.

    throws

    Error if basemap not found for the given id

    example
    
    // Activate the basemap "streets"
    JMap.Map.Basemap.activateById("streets")
    
    // Deactivate current basemap
    JMap.Map.Basemap.deactivate()

    Parameters

    • basemapId: string

      The basemap id, use JMap.Map.Basemap.getAllId() to get available basemap ids

    Returns void

add

  • add(basemap: JBasemap, activate?: undefined | false | true, beforeId?: undefined | string): void
  • JMap.Map.Basemap.add

    Add a new basemap on the map.

    You can find tile servers here : https://wiki.openstreetmap.org/wiki/Tile_servers

    throws

    if invalid parameters

    example
    
    // add an osm basemap
    JMap.Map.Basemap.add({
      id: "osm",
      label: "Open Street Map",
      tileUrls: [
        "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",
        "https://b.tile.openstreetmap.org/{z}/{x}/{y}.png",
        "https://c.tile.openstreetmap.org/{z}/{x}/{y}.png"
      ],
      previewImageAsUrlOrBase64: "https://searchengineland.com/figz/wp-content/seloads/2013/11/Screen-Shot-2013-11-22-at-3.41.27-PM.png"
     }, true) // true = activate the new basemap
    
    // Add a quadkey (not x/y/z) basemap
    JMap.Map.Basemap.add(
     {
       id: "My custom map",
       label: "My map",
       tileUrls: [
         "https://t.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=fr-CA&it=G,LC,BX,RL&shading=hill&n=z&og=1226&cstl=vb&src=o"
       ],
       previewImageAsUrlOrBase64: "http://www.toxel.com/wp-content/uploads/2008/08/creativelogos11.jpg"
     }, true) // true = activate the new basemap

    Parameters

    • basemap: JBasemap

      The basemap descriptor

    • Optional activate: undefined | false | true

      if true create the basemap and activate it

    • Optional beforeId: undefined | string

      if provided, add the basemap before the given id

    Returns void

deactivate

  • deactivate(): void
  • JMap.Map.Basemap.deactivate

    Deactivate the current active basemap on the map.

    Do nothing if no map is active.

    example
    
    // Deactivate current basemap
    JMap.Map.Basemap.deactivate()

    Returns void

existsById

  • existsById(basemapId: string): boolean
  • JMap.Map.Basemap.existsById

    Returs true if basemap exist for the given id.

    example
    
    // returns true if "streets" basemap exist
    JMap.Map.Basemap.existsById("streets")

    Parameters

    • basemapId: string

      The basemap id, use JMap.Map.Basemap.getAllId() to get available basemap ids

    Returns boolean

getActiveId

  • getActiveId(): string | undefined
  • JMap.Map.Basemap.getActiveId

    Returns the active basemap id, undefined is no basemap is activated.

    example
    
    // returns the active basemap id, undefined is no basemap is activated
    JMap.Map.Basemap.getActiveId()

    Returns string | undefined

getAllIds

  • getAllIds(): string[]
  • JMap.Map.Basemap.getAllIds

    Returns the available basemap ids that can be used with method activateById.

    Mapbox values are : "mapbox-light", "mapbox-streets", "mapbox-satellite", "mapbox-satellite-streets", "mapbox-dark", or "mapbox-outdoors"

    OSM value is : "osm-standard"

    example
    
    // returns an array of string containing all available basemap ids
    JMap.Map.Basemap.getAllIds()

    Returns string[]

    an array of string, the available basemap ids

getById

  • JMap.Map.Basemap.getById

    Returs the basemap descriptor for the given id.

    throws

    Error if basemap not found for the given id

    example
    
    // returns the "streets" basemap
    JMap.Map.Basemap.getById("streets")

    Parameters

    • basemapId: string

      The basemap id, use JMap.Map.Basemap.getAllId() to get available basemap ids

    Returns JBasemap

isActive

  • isActive(): boolean
  • JMap.Map.Basemap.isActive

    Returns true if a basemap is active on the map.

    example
    
    JMap.Map.Basemap.activateById("streets")
    
    // returns true
    JMap.Map.Basemap.isActive()
    
    JMap.Map.Basemap.deactivate()
    
    // returns false
    JMap.Map.Basemap.isActive()

    Returns boolean

isDisabled

  • isDisabled(): boolean
  • JMap.Map.Basemap.isDisabled

    Returns true if basemaps are disabled.

    Can be disabled with option disableBasemaps JCoreOptions in JS options, or with url param "ngDisableBasemaps=true".

    example
    
    JMap.Map.Basemap.isDisabled()

    Returns boolean

isMapboxId

  • isMapboxId(basemapId: string): boolean
  • JMap.Map.Basemap.isMapboxId

    Returns true if the basemap id is a mapbox basemap.

    example
    
    // returns true
    JMap.Map.Basemap.isMapboxId("mapbox-streets")
    
    // returns false
    JMap.Map.Basemap.isMapboxId("my-custom-basemap")

    Parameters

    • basemapId: string

    Returns boolean

isOSMId

  • isOSMId(basemapId: string): boolean
  • JMap.Map.Basemap.isOSMId

    Returns true if the basemap id is an Open Street Map basemap.

    example
    
    // returns true
    JMap.Map.Basemap.isOSMId("osm-standard")
    
    // returns false
    JMap.Map.Basemap.isOSMId("mapbox-streets")

    Parameters

    • basemapId: string

    Returns boolean

removeById

  • removeById(basemapId: string): void
  • JMap.Map.Basemap.removeById

    Remove a basemap for a given id.

    If id doesn't exist do nothing.

    If the active basemap is removed, no basemap will be displayed anymore.

    throws

    if missing basemap parameter

    example
    
    // Remove the "streets" basemap
    JMap.Map.Basemap.removeById("streets")

    Parameters

    • basemapId: string

      the basemap id

    Returns void

removeByIds

  • removeByIds(basemapIds: string[]): void
  • JMap.Map.Basemap.removeByIds

    Remove basemaps for the given ids.

    If an id doesn't exist it is ignored.

    If the active basemap is removed, no basemap will be displayed anymore.

    example
    
    // Remove two basemaps
    JMap.Map.Basemap.removeByIds([ "streets", "lights" ])

    Parameters

    • basemapIds: string[]

    Returns void