portal-webitem-map
This bundle allows to use items from ArcGIS Enterprise portal or ArcGIS Online in map.apps.
It creates a map-widget.MapWidget based on a JSON configuration referencing an item.
The resulting map widget is registered at the component system with the widget role map.
Usage
To configure the portal item in the app.json file, use:
{
"bundles": {
"portal-webitem-map": {
"Config": {
"portalItem": {
"id": "31874da8a16d45bfbc1273422f772270"
}
}
}
}
}
The default portal from which the item is loaded is configured by the application.properties key esri.api.arcgisPortalUrl.
An alternative is to configure the portal property:
{
"bundles": {
"portal-webitem-map": {
"Config": {
"portalItem": {
"id": "f001e7e2d9f94460a6c10cff4a9d03e6",
"portal": "https://myserver/arcgis"
}
}
}
}
}
It is possible to customize the view properties of the created SceneView or MapView by adding a view property to the configuration:
{
"bundles": {
"portal-webitem-map": {
"Config": {
"portalItem": {
"id": "f001e7e2d9f94460a6c10cff4a9d03e6",
"portal": "https://myserver/arcgis"
},
"view": {
"viewmode": "2D"
}
}
}
}
}
The view configuration is equal to the map-init bundle.
Motivation
This bundle provides a common JSON-based configuration format to reference a WebMap or WebScene from a portal.
The goals are:
- Provide a common configuration format for WebMaps and WebScenes.
- Provide a common place for the main map configuration with WebMap or WebScene in the
app.jsonfile. - Provide a way for other bundles to create custom map-widget based portal items.
Extended Use Cases
Create a non-default map widget
Custom bundles can reuse the configuration format to create custom map widgets.
A map widget can be created by using the configuration interpreter.
The configuration interpreter can be referenced by the following declaration in your manifest.json file:
{
"name": "YourComponent",
"references": [
{
"name": "interpreter",
"providing": "portal-webitem-map.Interpreter"
}
]
}
YourComponent can then trigger the interpretation of a portal item:
import { InjectedReference } from "apprt-core/InjectedReference";
import Map from "@arcgis/core/Map";
import { MapWidget, MapWidgetModel } from "map-widget/api";
interface InterpreterResult {
map: Map;
mapWidgetModel: MapWidgetModel;
mapWidget: MapWidget;
}
class MyComponent {
private interpreter: InjectedReference<any>;
async doSomething() {
// the map configuration
const portalItem = {} as any;
// trigger interpretation
const { map, mapWidgetModel, mapWidget }: InterpreterResult = await this.interpreter.interpret({ portalItem: portalItem }).toMapWidget();
// do something with the created parts
// if you are only interested in a MapWidgetModel do:
this.interpreter.interpret({ portalItem: portalItem }).toMapWidgetModel();
}
}