UNPKG

@arcgis/map-components

Version:
2 lines 2.85 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import b from"./FT372QJV.js";import a from"./HFRXDFTO.js";export default $arcgis.t(([{isZoomScreenSize:m},{d:g},{d:u}])=>{function q(e){if(e.icon)return e.icon;if(!("image"in e&&e.image)&&!e.className)return"question"}function M(e){return e?{backgroundImage:`url(${e})`}:{}}function b(e){let{selectedFeature:r,location:o,view:t}=e;return t?r??o??null:null}function v(e){return"browseClusterEnabled"in e&&"featureMenuOpen"in e}function h(e){return"aggregatedFeaturesEnabled"in e}async function E(e,r,o){let{location:t,selectedFeature:a,view:i,zoomFactor:n}=e;await o?.viewModel?.updateGeometry();let s=o?.graphic,d=s?.geometry?s:b(e);if(!i||!d)throw new Error("Cannot zoom to location without a target and view.");let w=i.scale/n,c=s?.geometry??e.selectedFeature?.geometry??t,l=c?.type==="point"&&await m(s??a,i);r.active=!0,r.disabled=!0;try{await e.zoomTo({target:{target:d,scale:l?w:void 0}})}catch(f){if(g(f))return;throw new Error("Could not zoom to the location of the graphic.")}finally{r.active=!1,r.disabled=!1,l&&e.location!==c&&(e.location=c)}}async function p(e,r){let o=await e.whenLayerView(u(r)),t=o.createQuery(),a=r.getObjectId();return t.aggregateIds=a!=null?[a]:[],[o,t]}async function y(e,r){let{selectedFeature:o,view:t}=e;if(t?.type!=="2d")throw new Error("zoomToAggregate:invalid-view: View must be 2d MapView.");if(!o?.isAggregate)throw new Error("zoomToAggregate:invalid-selectedFeature: Selected feature must represent an aggregate graphic.");let[a,i]=await p(t,o);r.active=!0,r.disabled=!0;let{extent:n}=await a.queryExtent(i);n&&await e.zoomTo({target:n}),r.active=!1,r.disabled=!1}var T=async(e,r)=>{if(!e)throw new Error("trigger-action:missing-arguments: Event has no action");let{disabled:o,id:t}=e;if(!t)throw new Error("trigger-action:invalid-action: action.id is missing");if(o)throw new Error("trigger-action:invalid-action: Action is disabled");if(t==="zoom-to-feature")return await E(r,e).catch(a=>{if(!g(a))throw a});if(t==="zoom-to-aggregated-features")return await y(r,e);if(t==="browse-clustered-features"){if(!v(r))throw new Error("trigger-action:invalid-view-model: browse-clustered-features requires FeaturesViewModel.");r.browseClusterEnabled=!r.browseClusterEnabled,r.featureMenuOpen=r.browseClusterEnabled;return}if(t==="browse-aggregated-features"){if(!h(r))throw new Error("trigger-action:invalid-view-model: browse-aggregated-features requires Features.");r.aggregatedFeaturesEnabled=!r.aggregatedFeaturesEnabled;return}if(t==="remove-selected-feature"){r.open=!1;let{selectedFeature:a}=r;if(!a)throw new Error("trigger-action:missing-selected-feature: Cannot remove selected feature without a selected feature.");let i=u(a);i?i.remove(a):r.view?.graphics.remove(a)}};return{a:q,b:M,c:E,d:T}},"applications/Components/actionUtils",a,b)