• 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.

    Parameters

    Returns void

    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"))
    })