Options
All
  • Public
  • Public/Protected
  • All
Menu

JMap.Event.MapContext.on

Here you have all JMap NG available map context events on which you can attach a listener.

Index

Functions

afterApply

  • afterApply(listenerId: string, fn: function): void
  • JMap.Event.MapContext.on.afterApply

    This event is triggered after the map context is applied.

    You can access extension's data from this event, see example below.

    example
    
    // Triggered after a map-context is applied
    JMap.Event.MapContext.on.afterApply("my-after-apply-listener", params => {
      console.info(`After apply map context id="${params.context.title}"`, params.context)
      const isExtensionDataSet = params.isExtensionDataSetById("my-extension")
      if (!isExtensionDataSet) {
        console.info("No extension data in map-context")
      } else {
        console.info("Extension map context data = ", params.getExtensionDataById("my-extension"))
      }
    })

    Parameters

    Returns void

afterMapDataChange

  • afterMapDataChange(listenerId: string, fn: function): void
  • JMap.Event.MapContext.on.afterMapDataChange

    This event is triggered after a context map data is created or updated.

    This event is not triggered when a context metadata is changed: title, description, default context, etc...

    You can access extension data from this event, see example below.

    example
    
    // Triggered after a map-context is created or updated
    JMap.Event.MapContext.on.afterMapDataChange("my-after-map-data-change-listener", params => {
      console.info(`After map data change for context id="${params.context.title}"`, params.context)
      console.info(`Is creation ="${params.isCreation}"`) // creation or update
      const isExtensionDataSet = params.isExtensionDataSetById("my-extension")
      if (isExtensionDataSet) {
        console.info("Saved extension data", params.getExtensionDataById("my-extension"))
      } else {
        console.info("No extension data")
      }
    })

    Parameters

    Returns void

applyError

  • applyError(listenerId: string, fn: function): void
  • JMap.Event.MapContext.on.applyError

    This event is triggered when an error occurs while applying a map-context.

    example
    
    // Triggered after a map-context error occurs
    JMap.Event.MapContext.on.applyError("my-apply-error-listener", params => {
      console.info(`An error occured while applying map context id="${params.context.title}"`, params.context)
    })

    Parameters

    Returns void

beforeApply

  • beforeApply(listenerId: string, fn: function): void
  • JMap.Event.MapContext.on.beforeApply

    This event is triggered before the map context is applied.

    You can access extension's data from this event, see example below.

    example
    
    // Triggered before a map-context is applied
    JMap.Event.MapContext.on.beforeApply("my-before-apply-listener", params => {
      console.info(`Before apply map context id="${params.context.title}"`, params.context)
      const isExtensionDataSet = params.isExtensionDataSetById("my-extension")
      if (!isExtensionDataSet) {
        console.info("No extension data in map-context")
      } else {
        console.info("Extension map context data = ", params.getExtensionDataById("my-extension"))
      }
    })

    Parameters

    Returns void

beforeMapDataChange

  • beforeMapDataChange(listenerId: string, fn: function): void
  • JMap.Event.MapContext.on.beforeMapDataChange

    This event is triggered before a context map data is created or updated.

    This event is not triggered when a context metadata is changed: title, description, default context, etc...

    You can access and manage extension's data from this event, see example below.

    example
    
    // Triggered before a map-context is created or updated
    JMap.Event.MapContext.on.beforeMapDataChange("my-before-map-data-changed-listener", params => {
      console.info(`Before map data changed for context id="${params.context.title}"`, params.context)
      console.info(`Is creation ="${params.isCreation}"`) // creation or update
      // you can check if some extension data has been set for this map-context
      const isExtensionDataSet = params.isExtensionDataSetById("my-extension")
      if (isExtensionDataSet) {
        // and you can delete this data if you want
        params.removeExtensionDataById("my-extension")
      }
      // it's not necessary to delete before setting the data, update will overwrite the existing data
      params.setExtensionDataById("my-extension", { count: 0, description: "your own extension data" })
      console.info("Extension data has been set and will be saved", params.getExtensionDataById("my-extension"))
    })

    Parameters

    Returns void

initialized

  • initialized(listenerId: string, fn: function): void
  • JMap.Event.MapContext.on.initialized

    This event is triggered when the map-context service is initialized.

    example
    
    // Triggered when map context is initialized
    JMap.Event.MapContext.on.initialized("custom-initialized-listener", params =>
      console.info("Map context service initialized", params)
    )

    Parameters

    Returns void