Options
All
  • Public
  • Public/Protected
  • All
Menu

Module MapContext

JMap.MapContext

You can manage map contexts here.

Index

Functions

addCssClassesToIgnoreForPreviewImage

  • addCssClassesToIgnoreForPreviewImage(classes: string[]): void
  • JMap.MapContext.addCssClassesToIgnoreForPreviewImage

    Add css classes in the list of css class to ignore/hide when processing the preview image.

    throws

    if given classes param is not a string array

    example
    
    // dom elements that having "my-class-that-is-visible-on-screen-but-want-to-hide-in-preview"
    // css class will be hidden in the preview image
    JMap.MapContext.addCssClassesToIgnoreForPreviewImage([
     "my-class-that-is-visible-on-screen-but-want-to-hide-in-preview"
    ])

    Parameters

    • classes: string[]

    Returns void

applyContextById

  • applyContextById(contextId: JId): Promise<void>
  • JMap.MapContext.applyContextById

    Apples the map context for a given id.

    throws

    if map-context not found

    example
    
    // load the map-context id=3 on screen
    JMap.MapContext.applyContextById(3)
     .then(() => console.info("Map context applied"))
     .catch(error => console.error(error))

    Parameters

    • contextId: JId

      the JMap map context id

    Returns Promise<void>

cancelCreation

  • cancelCreation(): void
  • JMap.MapContext.cancelCreation

    Hides the creation tab, input are cleared, and list of map-context are displayed.

    example
    
    // hide the new map-context tab
    JMap.MapContext.cancelCreation()

    Returns void

clearListFilter

  • clearListFilter(): void
  • JMap.MapContext.getListFilter

    If a filter is applied on the map context list, this function clears it.

    example
    
    // clear the current filter if exists
    JMap.MapContext.getListFilter()

    Returns void

create

  • JMap.MapContext.create

    Creates a map context. The map-context creation is persisted server-side.

    You just need to provide the context meta-data (= data that describe the context).

    The current map context will be saved.

    throws

    if invalid map context data provided, or server request error

    example
    
    // create a new map-context
    JMap.MapContext
       .create({
         title: "My city",
         description: "My city description",
         shareLink: false
       })
       .then(mapContext => console.info(`Map context id={mapContext.id} created !`))
       .catch(error => console.error(error))

    Parameters

    Returns Promise<JMapContext>

    the created map context, with it's id

deleteContextById

  • deleteContextById(contextId: JId | JId[]): Promise<void>
  • JMap.MapContext.deleteContextById

    Deletes the map context for a given id.

    The map-context deletion is persisted server-side.

    This is a full delete.

    throws

    if map-context not found, or server request error

    example
    
    // deletes the map-context id=5
    JMap.MapContext
       .deleteContextById(5)
       .then(() => console.info("Context 5 deleted !"))
       .catch(error => console.error(error))
    
    // deletes map-contexts id in [ 3, 5, 12 ]
    JMap.MapContext
       .deleteContextById([ 3, 5, 12 ])
       .then(() => console.info("Three map contexts have been deleted !"))
       .catch(error => console.error(error))

    Parameters

    • contextId: JId | JId[]

      the JMap map context id or an array of map context ids

    Returns Promise<void>

existsById

  • existsById(contextId: JId): boolean
  • JMap.MapContext.existsById

    Returns true if map context exists for a given id, else false.

    example
    
    // returns true if the map context id=3 exist, else false
    JMap.MapContext.existsById(3)

    Parameters

    • contextId: JId

      the JMap map context id

    Returns boolean

filterList

  • filterList(filter: string): void
  • JMap.MapContext.filterList

    Filters the map context list.

    The filter is done on "title" and/or "description".

    example
    
    // only map context having "ab" in title and/or description will be displayed
    JMap.MapContext.filterList("ab")

    Parameters

    • filter: string

      a string

    Returns void

getAll

  • JMap.MapContext.getAll

    Returns all map contexts fetched from server, for the given project.

    example
    
    // returns all map contexts for the current project
    JMap.MapContext.getAll()

    Returns JMapContext[]

getAllListSortBy

  • JMap.MapContext.getAllListSortBy

    Returns all available map context list sort : [ "alphabetic", "lastUpdate" ]

    example
    
    // returns all available list sort
    JMap.MapContext.getAllListSortBy()

    Returns JMAP_CONTEXT_SORT_BY_OPTIONS[]

getAllListSortDirection

  • JMap.MapContext.getAllListSortDirection

    Returns all available map context list sort directions : [ "asc", "desc" ]

    example
    
    // returns all available list sort directions
    JMap.MapContext.getAllListSortDirection()

    Returns JMAP_CONTEXT_SORT_BY_DIRECTIONS[]

getById

  • JMap.MapContext.getById

    Returns the map context for a given id.

    throws

    if map-context not found

    example
    
    // returns the map-context id=3
    JMap.MapContext.getById(3)

    Parameters

    • contextId: JId

      the JMap map context id

    Returns JMapContext

getContextDescription

  • getContextDescription(contextId: JId): string
  • JMap.MapContext.getContextDescription

    Returns the map context description for a given map context id.

    throws

    if map-context not found

    example
    
    // returns the map-context id=3 description
    JMap.MapContext.getContextDescription(3)

    Parameters

    • contextId: JId

      the JMap map context id

    Returns string

getContextTitle

  • getContextTitle(contextId: JId): string
  • JMap.MapContext.getContextTitle

    Returns the map context title for a given map context id.

    throws

    if map-context not found

    example
    
    // returns the map-context id=3 title
    JMap.MapContext.getContextTitle(3)

    Parameters

    • contextId: JId

      the JMap map context id

    Returns string

getDefaultContext

  • JMap.MapContext.getDefaultContext

    Returns the default map context if one has been set as default, else undefined.

    The default map context is loaded automatically at startup.

    example
    
    // returns the default map context if one has been set
    JMap.MapContext.getDefaultContext()

    Returns JMapContext | undefined

getIgnoredCssClassesForPreviewImage

  • getIgnoredCssClassesForPreviewImage(): string[]
  • JMap.MapContext.getIgnoredCssClassesForPreviewImage

    Add css classes in the list of css class to ignore/hide when processing the preview image.

    throws

    if given classes param is not a string array

    example
    
    // print in the console all css classes that will be ignored/hidden in the preview image
    console.info(
     "Css classes ignored when generating the preview image:",
     JMap.MapContext.getIgnoredCssClassesForPreviewImage()
    )

    Returns string[]

getListFilter

  • getListFilter(): string
  • JMap.MapContext.getListFilter

    Returns the currently applied filter on the map context list, or an empty string if no filter is applied.

    example
    
    // returns the current filter
    JMap.MapContext.getListFilter()

    Returns string

getListSortBy

getListSortDirection

  • JMap.MapContext.getListSortDirection

    Returns the map-context list sort direction.

    example
    
    // returns the list sort direction
    JMap.MapContext.getListSortDirection()

    Returns JMAP_CONTEXT_SORT_BY_DIRECTIONS

getPreviewImageSize

  • getPreviewImageSize(): JSize
  • JMap.MapContext.getPreviewImageSize

    Returns the preview image size.

    example
    
    // Print the preview image size in console.
    console.info("Preview image size", JMap.MapContext.getPreviewImageSize())

    Returns JSize

getUrlByUUID

  • getUrlByUUID(contextUUID: string): string
  • JMap.MapContext.getUrlByUUID

    Returns the map context url, accessible if the map context is shared.

    example
    
    // returns the map context url, accessible if the map context is shared
    JMap.MapContext.getUrlByUUID("qsdqsd-wsdwqd-wdwde-wedwdwd")

    Parameters

    • contextUUID: string

      the JMap map context UUID (not the id but the UUID)

    Returns string

isActive

  • isActive(): boolean
  • JMap.MapContext.isActive

    Returns false if the map context functionnality is not active.

    Some users don't have access to map context, like the anonymous or system user.

    If map context service is not avalable, user cannot access, create, update or delete context from the service.

    example
    
    // true if user can use map contexts
    JMap.MapContext.isActive()

    Returns boolean

isDefaultContext

  • isDefaultContext(contextId: JId): boolean
  • JMap.MapContext.isDefaultContext

    Returns true if the map context is the default one, given the id.

    The default map context is loaded automatically at startup.

    throws

    if map-context not found

    example
    
    // returns true if the map context id=3 is the default one.
    JMap.MapContext.isDefaultContext(3)

    Parameters

    • contextId: JId

      the JMap map context id

    Returns boolean

isLinkShared

  • isLinkShared(contextId: JId): boolean
  • JMap.MapContext.isLinkShared

    Returns true if the map context is shared, for a given map context id.

    throws

    if map-context not found

    example
    
    // returns true if the map-context id=3 is shared
    JMap.MapContext.isLinkShared(3)

    Parameters

    • contextId: JId

      the JMap map context id

    Returns boolean

setActive

  • JMap.MapContext.setActive

    Activate or deactivate mapcontext functionality.

    If map context functionality is not active, user cannot access, create, update or delete context from the service.

    throws

    if user cannot use the mapcontext (anonymous or system user for example), or if state initialization failed

    example
    
    // activate the mapcontext functionality
    JMap.MapContext.setActive(true)
     .then(result => console.info(result))
     .catch(error => console.error(error))
    
    // deactivate the mapcontext functionality
    JMap.MapContext.setActive(false)
     .then(result => console.info(result))
     .catch(error => console.error(error))

    Parameters

    • isActive: boolean

      true to activate, else false

    Returns Promise<JMapContextSetActiveResult>

setContextDescription

  • setContextDescription(contextId: JId, description: string): Promise<void>
  • JMap.MapContext.setContextDescription

    Updates a map context description, without changing the map data.

    The map-context description is persisted server-side.

    throws

    if context not found, or empty title, or server request error

    example
    
    // update the map-context id=3 description
    JMap.MapContext
       .setContextDescription(3, "My new description")
       .then(() => console.info(`Map context id=3 "description" updated`))
       .catch(error => console.error(error))

    Parameters

    • contextId: JId

      the JMap map context id

    • description: string

      the new description

    Returns Promise<void>

setContextTitle

  • setContextTitle(contextId: JId, title: string): Promise<void>
  • JMap.MapContext.setContextTitle

    Updates a map context title, without changing the map data.

    The map-context title is persisted server-side.

    throws

    if context not found, or empty title, or server request error

    example
    
    // update the map-context id=3 title
    JMap.MapContext
       .setContextTitle(3, "My new title")
       .then(() => console.info(`Map context id=3 "title" updated`))
       .catch(error => console.error(error))

    Parameters

    • contextId: JId

      the JMap map context id

    • title: string

      the new title

    Returns Promise<void>

setCreateDescription

  • setCreateDescription(newDescription: string): void
  • JMap.MapContext.setCreateDescription

    Set the description for the creation panel (visible in NG app only).

    throws

    if newDescription is not a string

    example
    
    // set the description in the redux store, used for new map context creation
    JMap.MapContext.setCreateDescription("New description")

    Parameters

    • newDescription: string

      the new description to display

    Returns void

setCreateTitle

  • setCreateTitle(newTitle: string): void
  • JMap.MapContext.setCreateTitle

    Set the title for the creation panel (visible in NG app only).

    throws

    if newTitle is not a string

    example
    
    // set the title in the redux store, used for new map context creation
    JMap.MapContext.setCreateTitle("New title")

    Parameters

    • newTitle: string

      the new title to display

    Returns void

setCreateTitleError

  • setCreateTitleError(hasError: boolean): void
  • JMap.MapContext.setCreateTitleError

    Set the title creation in error or not for the creation panel (visible in NG app only).

    example
    
    // set the title creation in error in the redux store, used for new map context creation
    JMap.MapContext.setCreateTitleError("New description")

    Parameters

    • hasError: boolean

      true or false

    Returns void

setDefaultContext

  • setDefaultContext(contextId?: JId): Promise<void>
  • JMap.MapContext.setDefaultContext

    Sets or unsets default map context, the change is persited server side.

    If a contextId is provided, sets the map context as the default one.

    If no context id is provided, unsets the current default context.

    throws

    if context provided but not found, or server request error

    example
    
    // set the map-context id=3 as the default one
    JMap.MapContext
       .setDefaultContext(3)
       .then(() => console.info(`Map context id=3 is now the default one`))
       .catch(error => console.error(error))

    // make no map-context as default JMap.MapContext .setDefaultContext() .then(() => console.info(No map context are default now)) .catch(error => console.error(error))

    Parameters

    • Optional contextId: JId

      the JMap map context id

    Returns Promise<void>

setLinkShare

  • setLinkShare(contextId: JId, isShared: boolean): Promise<void>
  • JMap.MapContext.setLinkShare

    Updates a map context link share state, without changing the map data.

    The map-context link share state is persisted server-side.

    throws

    if context not found, or empty title, or server request error

    example
    
    // update the map-context id=3 link share state to true
    JMap.MapContext
       .setLinkShare(3, true)
       .then(() => console.info(`Map context id=3 is now shared`))
       .catch(error => console.error(error))

    Parameters

    • contextId: JId

      the JMap map context id

    • isShared: boolean

      true if the link is shared, else false

    Returns Promise<void>

setListSortDirection

  • JMap.MapContext.setListSortDirection

    Changes the map-context list sort direction. The change is persited in local storage.

    "asc" : ascendant sort "desc" : descendant sort

    throws

    if sortByDirection param is not correct

    example
    
    // make the sort ascendant
    JMap.MapContext.setListSortDirection("asc")
    
    // make the sort descendant
    JMap.MapContext.setListSortDirection("desc")

    Parameters

    Returns void

setPreviewImageSize

  • setPreviewImageSize(size: JSize): void
  • JMap.MapContext.setPreviewImageSize

    Set the preview image size, by default size is :

    • Width: 100
    • Height: 100
    throws

    if given size is not an object having positive and greater than zero width and height

    example
    
    // set the review image size
    JMap.MapContext.setPreviewImageSize({
     width: 100,
     height: 200
    })

    Parameters

    Returns void

sortListBy

  • JMap.MapContext.sortListBy

    Changes the map-context list sort. The change is persited in local storage.

    "alphabetic" : list following map context title string "lastUpdate" : list following map context last update

    throws

    if sortBy param is not correct

    example
    
    // sort the list alphabetically
    JMap.MapContext.sortListBy("alphabetic")
    
    // sort the list with the last upadte date
    JMap.MapContext.sortListBy("lastUpdate")

    Parameters

    Returns void

startCreation

  • startCreation(): void
  • JMap.MapContext.startCreation

    Displays the new map-context tab on screen.

    example
    
    // display the new map-context tab on screen
    JMap.MapContext.startCreation()

    Returns void

update

  • JMap.MapContext.update

    Updates a map context, saves the current map context data.

    The map-context update is persisted server-side.

    You can provide partial meta-data (= data that describes the context), if a meta-data is not provided, it will not be changed.

    throws

    if context not found, or empty or invalid meta-data, or server request error

    example
    
    // update the map-context id=3
    JMap.MapContext
       .update(3, { title: "My new title" }) // only "title" meta-data will be changed, "description" and "shareLink" keep the same
       .then(mapContext => console.info(`Map context id=3 meta-data and map data updated.`, mapContext))
       .catch(error => console.error(error))

    Parameters

    • contextId: JId

      the JMap map context id

    • Optional params: JMapContextMetaData

      partial map context meta-data, only data provided will be updated

    Returns Promise<JMapContext>

    the updated map context

updateMetaData

  • JMap.MapContext.updateMetaData

    Updates a map context meta-data (= data that describe the context), without changing the map data.

    The map context map's data will not be changed, for that use JMap.MapContext.update function.

    The map-context meta-data is persisted server-side.

    You can provide partial meta-data, if a meta-data is not provided it will not be changed.

    throws

    if context not found, or empty or invalid meta-data, or server request error

    example
    
    // update the map-context id=3 meta-data
    JMap.MapContext
       .updateMetaData(3, { // only "title" and "description" meta-data will be changed, "shareLink" keep the same
         title: "My new title",
         descritpion: "My new description"
       })
       .then(mapContext => console.info(`Map context id=3 "title" and "description" updated.`, mapContext))
       .catch(error => console.error(error))

    Parameters

    Returns Promise<void>

    the updated map context