@arcgis/map-components
Version:
ArcGIS Map Components
80 lines (79 loc) • 3.86 kB
JavaScript
import { c as a } from "../../chunks/runtime.js";
import { usePropertyChange as r } from "@arcgis/components-controllers";
import { watch as h } from "@arcgis/core/core/reactiveUtils.js";
import o from "@arcgis/core/layers/RouteLayer.js";
import n from "@arcgis/core/widgets/Directions.js";
import { LitElement as d, createEvent as l, noShadowRoot as w } from "@arcgis/lumina";
import { m } from "../../chunks/useWidget.js";
import { f as u } 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.13 */
const c = y` {arcgis-directions{display:block}}`, g = m(n), i = "map-components:arcgis-directions";
class p extends d {
constructor() {
super(...arguments), this.widget = g(this), this.viewModel = this.widget.viewModel, this.apiKey = this.widget.apiKey, this.autoDestroyDisabled = !1, this.headingLevel = this.widget.headingLevel, this.hideLayerDetails = this.widget.visibleElements.layerDetails, this.hideSaveAsButton = this.widget.visibleElements.saveAsButton, this.hideSaveButton = this.widget.visibleElements.saveButton, this.icon = this.widget.icon, this.label = this.widget.label, this.lastRoute = this.widget.lastRoute, this.layer = this.widget.layer, this.maxStops = this.widget.maxStops, this.position = "bottom-left", this.searchProperties = this.widget.searchProperties, this.state = this.viewModel.state, this.unit = this.widget.unit, this.useDefaultRouteLayer = !1, this.arcgisPropertyChange = r()("lastRoute", "state"), this.arcgisReady = l();
}
static {
this.properties = { apiKey: 1, autoDestroyDisabled: 5, headingLevel: 9, hideLayerDetails: 5, hideSaveAsButton: 5, hideSaveButton: 5, icon: 1, label: 1, lastRoute: 0, layer: 0, maxStops: 9, position: 1, referenceElement: 1, routeLayerItemId: 1, searchProperties: 0, state: 0, unit: 1, useDefaultRouteLayer: 5 };
}
static {
this.shadowRootOptions = w;
}
static {
this.styles = c;
}
// #endregion
// #region Public Methods
/** Permanently destroy the component */
async destroy() {
await this.manager.destroy();
}
async getDirections() {
if (this.widget?.viewModel?.state !== "ready")
throw new Error(`${i} - component not ready to get directions`);
return await this.widget?.getDirections();
}
async save() {
if (this.widget?.viewModel?.state !== "ready")
throw new Error(`${i} - component not ready to save directions`);
return await this.widget?.save();
}
async saveAs(e, t) {
if (this.widget?.viewModel?.state !== "ready")
throw new Error(`${i} - component not ready to save directions as a Portal Item`);
return await this.widget?.saveAs(e, t);
}
async zoomToRoute() {
if (this.widget?.viewModel?.state !== "ready")
throw new Error(`${i} - component not ready to zoom to route`);
this.widget?.zoomToRoute();
}
// #endregion
// #region Lifecycle
willUpdate(e) {
if (e.has("routeLayerItemId")) {
const t = this.routeLayerItemId;
if (u(t) && !this.useDefaultRouteLayer) {
const { layer: s } = this;
s && this.widget.view?.map.remove(s), this._setDefaultLayer();
} else t && this.widget && (this.layer = new o({
portalItem: {
id: t
}
}), this.widget.view?.map.add(this.layer));
}
e.has("useDefaultRouteLayer") && this._setDefaultLayer();
}
// #endregion
// #region Private Methods
/** Maintain a default route layer */
_setDefaultLayer() {
this.useDefaultRouteLayer && !this.routeLayerItemId && (this.layer = new o(), h(() => this.widget.view, () => this.widget.view?.map.add(this.layer), { once: !0 }));
}
}
a("arcgis-directions", p);
export {
p as ArcgisDirections
};