Parses Basemap configurations.

Use service name "map-config-api.BasemapConfigParser" to inject an instance of this class.

interface BasemapConfigParser {
    parse(config: any, options?: any): Promise<{ instance: Basemap }>;
}

Methods

Methods

  • Parses a basemap configuration.

    Parameters

    • config: any

      See examples.

    • Optionaloptions: any

      Additional properties that will be merged into the basemap instance, e.g. title.

    Returns Promise<{ instance: Basemap }>

    A promise which resolves to &#123;instance: basemap&#125;.

    // string of well-known basemap
    const result = await configParser.parse("streets", { title: 'Streets' });
    // result instance is esri/Basemap, the well-known streets basemap, with custom title
    // string of well-known basemap
    const result = await configParser.parse({ id: "streets" });
    // result instance is esri/Basemap, the well-known streets basemap
    // config object with custom layer
    const result = await configParser.parse({
    title: "My Basemap",
    baseLayers: [{
    "url": "https://myarcgis.com/arcgis/rest/services/MyService/MapServer",
    "type": "AGS_TILED"
    }]
    });
    // result instance is esri/Basemap, with a custom layer
    // config object with custom layer, but shorter
    const result = await configParser.parse({
    "url": "https://myarcgis.com/arcgis/rest/services/MyService/MapServer",
    "type": "AGS_TILED"
    })
    // result instance is esri/Basemap, with a custom layer
    // config object with custom layers, but shorter
    const result = await configParser.parse([{
    "url": "https://myarcgis.com/arcgis/rest/services/MyService/MapServer",
    "type": "AGS_TILED"
    },
    {
    "url": "https://myarcgis.com/arcgis/rest/services/OtherService/MapServer",
    "type": "AGS_TILED"
    }])
    // result instance is esri/Basemap, with two custom layers