Skip to main content
Version: Current

Map Actions

  • os.addMapLayer(portal: ("map" | "miniMap"), layer: GeoJSONMapLayer): Promise<string>

    Adds a map layer to the map or miniMap portal.

    Returns a promise that resolves with the ID of the layer that was added.

    The first parameter is a ("map" | "miniMap") and is the portal that the layer should be added to. Either 'map' or 'miniMap'.

    The second parameter is a GeoJSONMapLayer and is the layer that should be added.

    Examples
    Add a GeoJSON layer to the map portal
    const layerId = await os.addMapLayer('map', {
    type: 'geojson',
    data: {
    type: "FeatureCollection",
    features: [
    {
    type: "Feature",
    geometry: { type: "Point", coordinates: [102.0, 0.5] },
    properties: { prop0: "value0" }
    },
    {
    type: "Feature",
    geometry: {
    type: "LineString",
    coordinates: [
    [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
    ]
    },
    properties: {
    prop0: "value0",
    prop1: 0.0
    }
    },
    {
    type: "Feature",
    geometry: {
    type: "Polygon",
    coordinates: [
    [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
    [100.0, 1.0], [100.0, 0.0]]
    ]
    },
    properties: {
    prop0: "value0",
    prop1: { "this": "that" }
    }
    }
    ]
    }
    });
  • os.removeMapLayer(layerId: string): Promise<void>

    Removes a layer from the map or miniMap portal.

    Returns a promise that resolves when the layer has been removed.

    The first parameter is a string and is the ID of the layer to remove.

    Examples
    Remove a layer from the map portal
    await os.removeMapLayer('my-layer-id');