Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

18 lines
7.6 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("exports ../../core/iteratorUtils ../../core/MapUtils ../../core/mathUtils ../../core/screenUtils ./interactiveToolUtils ../support/screenUtils".split(" "),function(q,w,x,r,y,z,k){function t(a){let e=null;x.someMap(a,({manipulator:c})=>{if(null!=c&&c.interactive){if(c.grabbing&&c.grabCursor)return e=c.grabCursor,!0;if(c.cursor)return e=c.cursor,!0}return!1});return e}function m(a,e,c){let d=null;c(b=>{if(null==b.manipulators||!z.areToolManipulatorsEditable(b))return!1;const f=b.manipulators.intersect(a,
e);if(null==f)return!1;d={tool:b,manipulator:f};return!0});return d}class A{constructor(){this._pointerLocations=new Map;this._hoveredManipulators=new Map;this._grabbedManipulators=new Map;this._draggedManipulators=new Map;this._revertToNullActiveTool=this._stopDrag=!1;this._cursor=null}get cursor(){return this._cursor}hasFocusedManipulators(){return 0<this._grabbedManipulators.size||0<this._draggedManipulators.size}handleInputEvent(a,e){var c=()=>a.stopPropagation();switch(a.type){case "pointer-move":"mouse"===
a.pointerType&&this._pointerLocations.set(a.pointerId,{x:a.x,y:a.y,pointerType:a.pointerType});break;case "drag":0<this._grabbedManipulators.size&&(this._stopDrag=!0);this._stopDrag&&(a.stopPropagation(),"end"===a.action&&(this._stopDrag=!1));break;case "pointer-down":if("mouse"===a.pointerType&&0!==a.button)break;c=k.createScreenPointFromEvent(a);var d=m(c,a.pointerType,e.forEachTool);if(null==d)break;var b=d.manipulator,f=d.tool;null==b||null==f||!b.interactive||b.grabbable&&b.grabbableForEvent(a)||
!b.grabbing||b.dragging||this._releaseManipulatorBeforeDragging(b,a,e);null!=b&&null!=f&&b.interactive&&b.grabbable&&b.grabbableForEvent(a)&&!b.grabbing&&(this._grabbedManipulators.set(a.pointerId,{manipulator:b,tool:f,start:c,pointerType:a.pointerType}),1===this._grabbedManipulators.size&&null==e.activeTool&&(this._revertToNullActiveTool=!0,e.setActiveTool(d.tool)),b.grabbing=!0,b.events.emit("grab-changed",{action:"start",pointerType:a.pointerType,screenPoint:c}),a.stopPropagation());break;case "pointer-up":this._draggedManipulators.has(a.pointerId)||
this._handlePointerEnd(a,e);break;case "pointer-drag":if("mouse"===a.pointerType&&0!==a.button)break;f=this._grabbedManipulators.get(a.pointerId);c=f?.manipulator;d=f?.tool;if(null==c||null==d)break;b=k.createScreenPointFromEvent(a);b.x=r.clamp(b.x,0,e.view.width);b.y=r.clamp(b.y,0,e.view.height);f=f.start;const g=this._draggedManipulators.get(a.pointerId);switch(a.action){case "start":case "update":if("update"===a.action||1===this._grabbedManipulators.size)c.dragging=!0,g?c.events.emit("drag",{action:"update",
start:f,screenPoint:b}):c.events.emit("drag",{action:"start",start:f,screenPoint:b,pointerType:a.pointerType}),this._draggedManipulators.set(a.pointerId,{tool:d,manipulator:c,start:f});break;case "end":c.dragging=!1,g&&c.events.emit("drag",{action:"end",start:f,screenPoint:b}),this._draggedManipulators.delete(a.pointerId),this._handlePointerEnd(a,e)}a.stopPropagation();break;case "immediate-click":d=k.createScreenPointFromEvent(a);const h=m(d,a.pointerType,e.forEachTool);a.native.shiftKey||e.forEachTool(n=>
{if((null==h||h.tool!==n||n.automaticManipulatorSelection)&&n.manipulators){let u=!1;n.manipulators.forEach(({manipulator:v})=>{v.selected&&(v.selected=!1,u=!0)});if(u&&n.onManipulatorSelectionChanged)n.onManipulatorSelectionChanged()}});if(null==h)break;const {manipulator:l,tool:p}=h;if(!l.interactive)break;if(l.selectable&&p.automaticManipulatorSelection&&(l.selected=!l.selected,p.onManipulatorSelectionChanged))p.onManipulatorSelectionChanged();l.events.emit("immediate-click",{screenPoint:d,button:a.button,
pointerType:a.pointerType,shiftKey:a.native.shiftKey,stopPropagation:c});l?.consumesClicks&&a.stopPropagation();break;case "click":c=k.createScreenPointFromEvent(a);d=m(c,a.pointerType,e.forEachTool)?.manipulator;if(null==d||!d.interactive)break;d.events.emit(a.type,{screenPoint:c,button:a.button,pointerType:a.pointerType,shiftKey:a.native.shiftKey});a.stopPropagation();break;case "double-click":d=k.createScreenPointFromEvent(a);b=m(d,a.pointerType,e.forEachTool);b=null!=b?b.manipulator:null;if(null==
b||!b.interactive)break;b.events.emit("double-click",{screenPoint:d,button:a.button,pointerType:a.pointerType,shiftKey:a.native.shiftKey,stopPropagation:c});b?.consumesClicks&&a.stopPropagation();break;case "immediate-double-click":d=k.createScreenPointFromEvent(a),b=m(d,a.pointerType,e.forEachTool),b=null!=b?b.manipulator:null,null!=b&&b.interactive&&(b.events.emit("immediate-double-click",{screenPoint:d,button:a.button,pointerType:a.pointerType,shiftKey:a.native.shiftKey,stopPropagation:c}),b?.consumesClicks&&
a.stopPropagation())}this._onFocusChange(e.forEachTool)}_releaseManipulatorBeforeDragging(a,e,c){a.grabbing=!1;a.events.emit("grab-changed",{action:"end",pointerType:e.pointerType,screenPoint:k.createScreenPointFromEvent(e)});this._grabbedManipulators.forEach(({manipulator:d},b)=>{d===a&&this._grabbedManipulators.delete(b)});this._afterManipulatorRelease(c.setActiveTool)}_handlePointerEnd(a,e){const c=this._grabbedManipulators.get(a.pointerId)?.manipulator;null!=c&&c.grabbing&&(c.grabbing=!1,c.events.emit("grab-changed",
{action:"end",pointerType:a.pointerType,screenPoint:k.createScreenPointFromEvent(a)}),this._grabbedManipulators.delete(a.pointerId),this._afterManipulatorRelease(e.setActiveTool))}_onFocusChange(a){this._updateCursor();this._updateFocusedManipulatorTools(a)}_updateCursor(){this._cursor=0<this._grabbedManipulators.size?t(this._grabbedManipulators)||"grabbing":0<this._hoveredManipulators.size?t(this._hoveredManipulators)||"pointer":null}_updateFocusedManipulatorTools(a){const e=new Set,c=new Set;this._grabbedManipulators.forEach(({tool:d})=>
{e.add(d)});this._hoveredManipulators.forEach(({tool:d})=>{c.add(d)});a(d=>{d.hasGrabbedManipulators=e.has(d);d.hasHoveredManipulators=c.has(d);var b=this._grabbedManipulators.values();b=w.find(b,({tool:f})=>f===d);d.firstGrabbedManipulator=null!=b?b.manipulator:null})}clearPointers(a,{forEachTool:e,setActiveTool:c},d=!0,b){this._grabbedManipulators.forEach(({tool:f,manipulator:g,pointerType:h},l)=>{f!==a||null!=b&&b!==g||(this._grabbedManipulators.delete(l),g.grabbing=!1,g.events.emit("grab-changed",
{action:"end",screenPoint:null,pointerType:h}))});this._draggedManipulators.forEach(({tool:f,manipulator:g},h)=>{f!==a||null!=b&&b!==g||(this._draggedManipulators.delete(h),g.dragging=!1,g.events.emit("drag",{action:"cancel"}))});d&&this._hoveredManipulators.forEach(({tool:f,manipulator:g},h)=>{f!==a||null!=b&&b!==g||(this._hoveredManipulators.delete(h),g.hovering=!1)});this._afterManipulatorRelease(c);this._onFocusChange(e)}updateHoveredStateFromKnownPointers(a){this._pointerLocations.forEach((e,
c)=>{this._updateHoveredStateForPointerAtScreenPosition(y.createScreenPoint(e.x,e.y),c,e.pointerType,a)})}handleHoverEvent(a,e){"pointer-up"!==a.type&&"immediate-click"!==a.type&&"pointer-move"!==a.type||"mouse"!==a.pointerType||this._updateHoveredStateForPointerAtScreenPosition(k.createScreenPointFromEvent(a),a.pointerId,a.pointerType,e)}_updateHoveredStateForPointerAtScreenPosition(a,e,c,d){a=m(a,c,d);c=this._hoveredManipulators.get(e)?.manipulator;null==a||a.manipulator.interactive||(a=null);if(null==
a||c!==a.manipulator)null!=c&&(c.hovering=!1),null!=a?(a.manipulator.hovering=!0,this._hoveredManipulators.set(e,a)):this._hoveredManipulators.delete(e),this._onFocusChange(d)}_afterManipulatorRelease(a){0===this._grabbedManipulators.size&&this._revertToNullActiveTool&&(a(null),this._revertToNullActiveTool=!1)}}q.ToolViewManagerManipulatorState=A;Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});