UNPKG

@arcgis/map-components

Version:
5 lines (4 loc) 2.7 kB
/*! 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 */ import{a as b}from"./GND5YSKD.js";import{a as E}from"./NYXWVKGC.js";import{a as w}from"./QKQNYHUC.js";import{a as r}from"./KWBN5CHV.js";import{d as a}from"./JM4XJJFL.js";import"./AX2MGWNF.js";import{A as g,B as v,C as s,E as u,G as f,a as d,g as h,q as p,r as m,s as t}from"./NIZJVZRG.js";var O=await $arcgis.l("widgets/Locate/LocateViewModel");var L=m`@layer{arcgis-locate{display:block}}`,T={base:"esri-locate"},M="gps-off",P=E(O),l=class extends v{constructor(){super(...arguments),this.messages=w(),this.viewModel=P(this),this.autoDestroyDisabled=!1,this.geolocationOptions=this.viewModel.geolocationOptions,this.goToLocationDisabled=this.viewModel.goToLocationEnabled,this.goToOverride=this.viewModel.goToOverride,this.graphic=this.viewModel.graphic,this.icon=M,this.popupDisabled=this.viewModel.popupEnabled,this.position="top-left",this.scale=this.viewModel.scale,this.state=this.viewModel.state,this.arcgisError=a(()=>this.viewModel,"locate-error"),this.arcgisPropertyChange=p()("state"),this.arcgisReady=g(),this.arcgisSuccess=a(()=>this.viewModel,"locate")}static{this.properties={autoDestroyDisabled:5,geolocationOptions:1,goToLocationDisabled:7,goToOverride:0,graphic:0,icon:3,label:1,messageOverrides:0,popupDisabled:5,position:3,referenceElement:1,scale:9,state:3}}static{this.shadowRootOptions=h}static{this.styles=L}async cancelLocate(){this.viewModel.cancelLocate()}async destroy(){await this.manager.destroy()}async locate(){return await this.viewModel.locate()}_localizeError(e){if(e instanceof GeolocationPositionError)return e.code===GeolocationPositionError.PERMISSION_DENIED?this.messages?.permissionError:e.code===GeolocationPositionError.TIMEOUT?this.messages?.timeoutError:this.messages?.positionUnavailable;if(e instanceof Error)return e.message}_locate(){let{viewModel:e}=this;e.state==="locating"?e.cancelLocate():e.locate().catch(()=>{})}render(){let{viewModel:e,icon:y}=this,{state:o}=e,i=o==="locating",c=i?this.messages.cancel:this.messages.title,$=o==="feature-unsupported",D=b===void 0?M:void 0,n=this._localizeError(this.viewModel?.error);return t`<div class=${s(d(T.base,r.widget))}>${!$&&t`<calcite-button class=${s(r.widgetButton)} .disabled=${o==="disabled"} .iconStart=${i?void 0:y??D} kind=neutral .label=${c} @click=${this._locate} title=${c??u}>${i?t`<calcite-loader inline label></calcite-loader>`:null}</calcite-button>`||""}${n?t`<calcite-tooltip open overlay-positioning=fixed .referenceElement=${this.el}>${n}</calcite-tooltip>`:null}</div>`}};f("arcgis-locate",l);export{l as ArcgisLocate};