@arcgis/map-components
Version:
ArcGIS Map Components
207 lines (206 loc) • 11.3 kB
JavaScript
import { c as v } from "../../chunks/runtime.js";
import { makeAccessorController as h, reEmitEvent as t, accessorSupport as d } from "@arcgis/components-controllers/accessor";
import { watch as s } from "@arcgis/core/core/reactiveUtils.js";
import p from "@arcgis/core/views/LinkChartView.js";
import n from "@arcgis/core/WebLinkChart.js";
import { LitElement as l, createEvent as a, noShadowRoot as m } from "@arcgis/lumina";
import { e as r, i as g } from "../../chunks/component-utils.js";
import { css as y } from "@lit/reactive-element/css-tag.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
v4.32.14 */
const u = y`{.arcgis-link-chart{padding:0;margin:0;height:100%;width:100%}}`, f = h(
n,
/**
* Since omitProps is only needed for typing, not runtime, `{} as { ... }` is
* a hack to remove them from the runtime code. This argument is not used at
* all at runtime. For makeViewModelController and makeWidgetController, the
* minifier is able to remove them automatically. However, minifier does not
* remove them for makeAccessorController as makeAccessorController is defined
* in an externalized package.
*/
{}
), _ = h(p, {});
class V extends l {
constructor() {
super(...arguments), this._center = void 0, this._extent = void 0, this._itemId = void 0, this._scale = void 0, this._viewpoint = void 0, this._zoom = void 0, this._map = f(this, {
editConstructorProperties: this._editMapProperties
}), this.view = _(this, { editConstructorProperties: this._editViewProperties }), this.allLayerViews = this.view.allLayerViews, this.autoDestroyDisabled = !1, this.background = this.view.background, this.basemap = this._map.basemap, this.basemapView = this.view.basemapView, this.constraints = this.view.constraints, this.displayFilterDisabled = this.view.displayFilterEnabled, this.fatalError = this.view.fatalError, this.graphics = this.view.graphics, this.highlights = this.view.highlights, this.layerViews = this.view.layerViews, this.magnifier = this.view.magnifier, this.map = this.view.map, this.navigation = this.view.navigation, this.padding = this.view.padding, this.popup = this.view.popup, this.popupDisabled = this.view.popupEnabled, this.ready = this.view.ready, this.resizeAlign = this.view.resizeAlign, this.resolution = this.view.resolution, this.rotation = this.view.rotation, this.spatialReference = this.view.spatialReference, this.suspended = this.view.suspended, this.theme = this.view.theme, this.timeExtent = this.view.timeExtent, this.timeZone = this.view.timeZone, this.updating = this.view.updating, this.arcgisViewChange = a(), this.arcgisViewClick = t(() => this.view, "click"), this.arcgisViewDoubleClick = t(() => this.view, "double-click"), this.arcgisViewDrag = t(() => this.view, "drag"), this.arcgisViewHold = t(() => this.view, "hold"), this.arcgisViewImmediateClick = t(() => this.view, "immediate-click"), this.arcgisViewImmediateDoubleClick = t(() => this.view, "immediate-double-click"), this.arcgisViewKeyDown = t(() => this.view, "key-down"), this.arcgisViewKeyUp = t(() => this.view, "key-up"), this.arcgisViewLayerviewCreate = t(() => this.view, "layerview-create"), this.arcgisViewLayerviewCreateError = t(() => this.view, "layerview-create-error"), this.arcgisViewLayerviewDestroy = t(() => this.view, "layerview-destroy"), this.arcgisViewMouseWheel = t(() => this.view, "mouse-wheel"), this.arcgisViewPointerDown = t(() => this.view, "pointer-down"), this.arcgisViewPointerEnter = t(() => this.view, "pointer-enter"), this.arcgisViewPointerLeave = t(() => this.view, "pointer-leave"), this.arcgisViewPointerMove = t(() => this.view, "pointer-move"), this.arcgisViewPointerUp = t(() => this.view, "pointer-up"), this.arcgisViewReadyChange = a();
}
static {
this.properties = { _map: 16, view: 32, allLayerViews: 0, autoDestroyDisabled: 5, background: 0, basemap: 1, basemapView: 0, center: 1, constraints: 0, displayFilterDisabled: 5, extent: 0, fatalError: 0, graphics: 0, highlights: 0, interacting: 32, itemId: 3, layerViews: 0, magnifier: 0, map: 0, navigating: 32, navigation: 0, padding: 0, popup: 0, popupDisabled: 5, ready: 4, resizeAlign: 1, resolution: 8, rotation: 9, scale: 9, spatialReference: 0, stationary: 32, suspended: 7, theme: 0, timeExtent: 0, timeZone: 1, updating: 7, viewpoint: 0, zoom: 9 };
}
static {
this.shadowRootOptions = m;
}
static {
this.styles = u;
}
/**
* Represents the view's center point; when setting the center, you may pass a
* esri/geometry/Point instance or a string representing
* a longitude/latitude pair (`"-100.4593, 36.9014"`).
* Setting the center immediately changes the current view.
* For animating the view, see this component's goTo() method.
*/
get center() {
return this.view.center ?? this._center;
}
set center(i) {
const e = r(i, this.ready ? this.view : void 0);
e && (this.ready && (this.view.center = e), this._center = e);
}
/**
* The extent represents the visible portion of a link chart within the view as an instance of
* [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html).
* Setting the extent immediately changes the view without animation. To animate
* the view, see this component's goTo() method.
* When the view is rotated, the extent does not update to include the newly visible portions of the link chart.
*/
get extent() {
return this.view.extent ?? this._extent;
}
set extent(i) {
this.view.ready && !this.extent?.equals(i) && (this.view.extent = i), this._extent = i;
}
/** Indication whether the view is being interacted with (for example when panning or by an interactive tool). */
get interacting() {
return this.view.interacting;
}
/** The ID of a WebLinkChart from an ArcGIS Enterprise portal.
*
* To configure the portal url you must set the [`portalUrl` property on `config`](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) before the `arcgis-linkchart` component loads.
*/
get itemId() {
return this._map.portalItem?.id ?? this._itemId;
}
set itemId(i) {
this._itemId = i, this.ready ? d.reCreate(this._map, this).then(() => {
this.view.map = this._map;
}).catch(console.error) : this.view.ready != null && (this._map.destroy(), this._map = new n(this._editMapProperties({ portalItem: { id: this._itemId } })), this.view.map = this._map);
}
/** Indication whether the view is being navigated (for example when panning). */
get navigating() {
return this.view.navigating;
}
/**
* Represents the link chart scale at the center of the view. Setting the scale immediately changes the view. For animating
* the view, see this component's goTo() method.
*/
get scale() {
return this.view.scale ?? this._scale;
}
set scale(i) {
this.ready && (this.view.scale = i), this._scale = i;
}
/** Indication whether the view is animating, being navigated with or resizing. */
get stationary() {
return this.view.stationary;
}
/**
* Represents the current view as a Viewpoint or point of observation on the view.
* Setting the viewpoint immediately changes the current view. For animating
* the view, see this component's goTo() method.
*/
get viewpoint() {
return this.view.viewpoint ?? this._viewpoint;
}
set viewpoint(i) {
this.ready && g(this.viewpoint, i) && (this.view.viewpoint = i), this._viewpoint = i;
}
/**
* Represents the level of detail (LOD) at the center of the view.
* A zoom level (or scale) is a number that defines how large or small the contents of a link chart appear in a link chart view.
* Zoom level is a number usually between 0 (global view) and 23 (very detailed view) and is used as a shorthand for predetermined scale values.
* A value of -1 means the view has no LODs.
* When setting the zoom value, the LinkChartView converts it to the corresponding scale, or interpolates it if the zoom is a fractional number.
* LinkChartView can display link charts with different projections at a full range of scales, and so use the scale property on this component rather than zoom level.
*
* Setting the zoom immediately changes the current view. For animating the view, see this component's goTo() method.
* Setting this property in conjunction with `center` is a convenient way to set the initial extent of the view.
*/
get zoom() {
return this.view.zoom ?? this._zoom;
}
set zoom(i) {
this.ready && (this.view.zoom = i), this._zoom = i;
}
//#endregion
//#region Public Methods
/** Adds a layer to the layers collection. */
async addLayer(i, e) {
this.map?.add(i, e);
}
/** Adds a layer or array of layers to the layers collection. */
async addLayers(i, e) {
this.map?.addMany(i, e);
}
/** Closes the popup. */
async closePopup() {
this.view?.closePopup();
}
/** Destroys the view, and any associated resources, including its map, popup, and UI elements. */
async destroy() {
await this.manager.destroy();
}
/** Sets the view to a given target. */
async goTo(i, e) {
return await this.view?.goTo(i, e);
}
/**
* Opens the popup at the given location with content defined either explicitly with content or driven
* from the PopupTemplate of input features.
*/
async openPopup(i) {
await this.view?.openPopup(i);
}
toMap(i) {
return this.view.toMap(i);
}
toScreen(i, e) {
return this.view.toScreen(i, e);
}
/** Call this method to clear any fatal errors resulting from a lost WebGL context. */
async tryFatalErrorRecovery() {
this.view?.tryFatalErrorRecovery();
}
/** Gets the LayerView created on the view for the given layer. */
async whenLayerView(i) {
return await this.view?.whenLayerView(i);
}
//#endregion
//#region Lifecycle
load() {
this.el.childElem = document.createElement("div"), this.el.childElem.classList.add("arcgis-link-chart"), this.el.append(this.el.childElem), this.view.container ??= this.el.childElem;
}
loaded() {
this.manager.onLifecycle(() => [
s(() => this.view.stationary, () => {
this.arcgisViewChange.emit();
}, { initial: !0 }),
s(() => this.view.ready, () => {
this.arcgisViewReadyChange.emit();
}, { initial: this.view.ready })
]);
}
//#endregion
//#region Private Methods
_editMapProperties(i) {
this.map && (this._map = this.map), this.itemId && (i.portalItem = { id: this.itemId });
const { basemap: e, ...o } = i;
e || (i = o);
const { ground: w, ...c } = i;
return w || (i = c), i;
}
async _editViewProperties(i) {
await this.manager.use(this._map), this.view.ui || (i.ui = {
components: ["attribution"]
}), i.map ??= this._map;
const e = r(this.center, void 0);
return e && (i.center = e), this.viewpoint && (i.viewpoint = this.viewpoint), this.scale !== void 0 && (i.scale = this.scale), this.extent && (i.extent = this.extent), this.zoom !== void 0 && (i.zoom = this.zoom), i;
}
}
v("arcgis-link-chart", V);
export {
V as ArcgisLinkChart
};