gisviewer-vue3-arcgis 1.0.221 → 1.0.223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/es/src/gis-map/gis-map.vue.d.ts +4 -0
  2. package/es/src/gis-map/gis-map.vue.mjs +106 -100
  3. package/es/src/gis-map/index.d.ts +4 -0
  4. package/es/src/gis-map/style/index.css +1 -1
  5. package/es/src/gis-map/utils/holo-flow/index.d.ts +3 -1
  6. package/es/src/gis-map/utils/holo-flow/index.mjs +34 -17
  7. package/es/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.d.ts +2 -0
  8. package/es/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.mjs +44 -26
  9. package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +36 -4
  10. package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.mjs +182 -105
  11. package/es/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +1 -1
  12. package/es/src/gis-map/utils/holo-flow/signal-holo-flow.mjs +1 -1
  13. package/es/src/gis-map/utils/map-initializer.mjs +102 -93
  14. package/lib/src/gis-map/gis-map.vue.d.ts +4 -0
  15. package/lib/src/gis-map/gis-map.vue.js +1 -1
  16. package/lib/src/gis-map/index.d.ts +4 -0
  17. package/lib/src/gis-map/style/index.css +1 -1
  18. package/lib/src/gis-map/utils/holo-flow/index.d.ts +3 -1
  19. package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
  20. package/lib/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.d.ts +2 -0
  21. package/lib/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.js +1 -1
  22. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +36 -4
  23. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.js +1 -1
  24. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +1 -1
  25. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -1
  26. package/lib/src/gis-map/utils/map-initializer.js +1 -1
  27. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("vue"),y=require("../../stores/index.js");function w(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const f=w(d);class m{constructor(e){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=80,this.canvasHeight=40,this.view=(e.type==="2d",e);const t=y.default.useAppDataStore;this.mapConfig=g.toRaw(t.mapConfig)}async initializeLayer(){try{await this.initializePlateBackground()}catch(e){console.log("倒计时背景图片加载失败",e)}if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,s=(await(await fetch(e)).json()).features.map((i,n)=>({geometry:{type:"polyline",paths:[i.geometry.coordinates]},attributes:{ObjectID:n+1,id:i.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:s,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer)}}async initializePlateBackground(){return new Promise((e,t)=>{const a=new Image;a.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,a.onload=()=>{this.plateBackground=a,e()},a.onerror=s=>{t(s)}})}async handleSignalData(e){const{crossId:t,lat:a,lon:s,rtStage:i,channelsConfig:n}=e;await this.updateCountdown(t,a,s,i),!(!this.phaseLineLayer||!n)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==i.stagePhase)&&await this.updatePhaseLine(t,i.channelsConfig,n),this.currentPhaseMap.set(t,i.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(e=>{this.view.container.removeChild(e.backgroundCanvas),this.view.container.removeChild(e.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(e,t,a,s){if(this.isDeletingCanvas)return;const i=this.countdownCanvasMap.get(e);if(i)this.drawCountdownText(i.countdownCanvas,s);else try{const n=new u.Point({longitude:a,latitude:t,z:10}),o=this.view.toScreen(n),l=this.createCountdownCanvas();if(!l)return;const h=l[0],c=l[1];h.style.left=o.x+"px",h.style.top=o.y+"px",c.style.left=o.x+"px",c.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:h,countdownCanvas:c,mapPoint:n}),this.drawCountdownText(c,s)}catch(n){console.log("倒计时canvas创建失败",e,n)}this.countdownWatchHandel||(this.countdownWatchHandel=f.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(n=>{const o=this.view.toScreen(n.mapPoint);n.backgroundCanvas.style.left=o.x+"px",n.backgroundCanvas.style.top=o.y+"px",n.countdownCanvas.style.left=o.x+"px",n.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const a=e.getContext("2d");a.clearRect(0,0,e.width,e.height),a.font="24px Digital",a.textBaseline="middle",a.textAlign="center",a.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",a.fillText(t.stageRemainingTime.toFixed(0),e.width/2,e.height/2)}async updatePhaseLine(e,t,a){const s=this.phaseLineLayer.source.filter(i=>i.getAttribute("id").includes(e));s.forEach(i=>{const n=i.getAttribute("id");this.isLaneInChannels(n,t)?i.setAttribute("color","green"):this.isLaneInChannels(n,a)?i.setAttribute("color","red"):i.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:s})}isLaneInChannels(e,t){const a=e.split("+"),s=a[1],i=a[2];for(let n=0;n<t.length;n++)for(let o=0;o<t[n].laneSnList.length;o++){const l=t[n].laneSnList[o].toFixed(0);if(s===l[0]&&i===l[1])return!0}return!1}createCountdownCanvas(){const e=document.createElement("canvas");e.width=this.canvasWidth,e.height=this.canvasHeight,e.style.position="absolute",e.style.transform="translate(-50%, -50%)";const t=e.getContext("2d");this.plateBackground?t.drawImage(this.plateBackground,0,0,this.canvasWidth,this.canvasHeight):(t.strokeStyle="rgba(0, 255, 0, 1)",t.lineWidth=1,t.strokeRect(0,0,this.canvasWidth,this.canvasHeight),t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,this.canvasWidth,this.canvasHeight)),this.view.container.appendChild(e);const a=document.createElement("canvas");return a.width=this.canvasWidth-10,a.height=this.canvasHeight-10,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",this.view.container.appendChild(a),[e,a]}}exports.default=m;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/core/reactiveUtils"),u=require("@arcgis/core/geometry"),p=require("@arcgis/core/layers/FeatureLayer"),g=require("vue"),y=require("../../stores/index.js");function w(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const f=w(d);class m{constructor(e){this.currentPhaseMap=new Map,this.countdownCanvasMap=new Map,this.lastDataTime=0,this.isDeletingCanvas=!1,this.canvasWidth=80,this.canvasHeight=40,this.view=(e.type==="2d",e);const t=y.default.useAppDataStore;this.mapConfig=g.toRaw(t.mapConfig)}async initializeLayer(){try{await this.initializePlateBackground()}catch(e){console.log("倒计时背景图片加载失败",e)}if(this.mapConfig.phaseLineLayer)if(this.phaseLineLayer)this.phaseLineLayer.visible||(this.phaseLineLayer.visible=!0);else{const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.phaseLineLayer}`,s=(await(await fetch(e)).json()).features.map((i,n)=>({geometry:{type:"polyline",paths:[i.geometry.coordinates]},attributes:{ObjectID:n+1,id:i.properties.id,color:"hide"}}));this.phaseLineLayer=new p({source:s,geometryType:"polyline",objectIdField:"ObjectID",outFields:["*"],fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"color",alias:"color",type:"string"}],renderer:{type:"unique-value",field:"color",defaultSymbol:{type:"simple-line",color:"lightblue",width:"2px",style:"none"},uniqueValueInfos:[{value:"green",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[19,255,69,.8]},width:1,height:.5}]}},{value:"red",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[254,5,9,.8]},width:1,height:.5}]}},{value:"yellow",symbol:{type:"line-3d",symbolLayers:[{type:"path",profile:"quad",material:{color:[255,215,0,.8]},width:1,height:.5}]}}]}}),this.view.map.add(this.phaseLineLayer)}}async initializePlateBackground(){return new Promise((e,t)=>{const a=new Image;a.src=`${this.mapConfig.assetsRoot}/Images/timeboard/CountdownBG.png`,a.onload=()=>{this.plateBackground=a,e()},a.onerror=s=>{t(s)}})}async handleHoloSignalData(e){const{crossId:t,lat:a,lon:s,rtStage:i,channelsConfig:n}=e;await this.updateCountdown(t,a,s,i),!(!this.phaseLineLayer||!n)&&((!this.currentPhaseMap.has(t)||this.currentPhaseMap.get(t)!==i.stagePhase)&&await this.updatePhaseLine(t,i.channelsConfig,n),this.currentPhaseMap.set(t,i.stagePhase))}clearSignal(){this.phaseLineLayer&&(this.phaseLineLayer.visible=!1),this.countdownWatchHandel&&(this.countdownWatchHandel.remove(),this.countdownWatchHandel=void 0),this.countdownCanvasMap.forEach(e=>{this.view.container.removeChild(e.backgroundCanvas),this.view.container.removeChild(e.countdownCanvas)}),this.countdownCanvasMap.clear()}async updateCountdown(e,t,a,s){if(this.isDeletingCanvas)return;const i=this.countdownCanvasMap.get(e);if(i)this.drawCountdownText(i.countdownCanvas,s);else try{const n=new u.Point({longitude:a,latitude:t,z:10}),o=this.view.toScreen(n),r=this.createCountdownCanvas();if(!r)return;const h=r[0],c=r[1];h.style.left=o.x+"px",h.style.top=o.y+"px",c.style.left=o.x+"px",c.style.top=o.y+"px",this.countdownCanvasMap.set(e,{backgroundCanvas:h,countdownCanvas:c,mapPoint:n}),this.drawCountdownText(c,s)}catch(n){console.log("倒计时canvas创建失败",e,n)}this.countdownWatchHandel||(this.countdownWatchHandel=f.watch(()=>this.view.extent,()=>{this.countdownCanvasMap.forEach(n=>{const o=this.view.toScreen(n.mapPoint);n.backgroundCanvas.style.left=o.x+"px",n.backgroundCanvas.style.top=o.y+"px",n.countdownCanvas.style.left=o.x+"px",n.countdownCanvas.style.top=o.y+"px"})}))}drawCountdownText(e,t){const a=e.getContext("2d");a.clearRect(0,0,e.width,e.height),a.font="24px Digital",a.textBaseline="middle",a.textAlign="center",a.fillStyle=t.stageRemainingTime<=t.stageAllRedTime?"red":t.stageRemainingTime<=t.stageAllRedTime+t.stageYellowTime?"yellow":"lime",a.fillText(t.stageRemainingTime.toFixed(0),e.width/2,e.height/2)}async updatePhaseLine(e,t,a){const s=this.phaseLineLayer.source.filter(i=>i.getAttribute("id").includes(e));s.forEach(i=>{const n=i.getAttribute("id");this.isLaneInChannels(n,t)?i.setAttribute("color","green"):this.isLaneInChannels(n,a)?i.setAttribute("color","red"):i.setAttribute("color","green")}),await this.phaseLineLayer.applyEdits({updateFeatures:s})}isLaneInChannels(e,t){const a=e.split("+"),s=a[1],i=a[2];for(let n=0;n<t.length;n++)for(let o=0;o<t[n].laneSnList.length;o++){const r=t[n].laneSnList[o].toFixed(0);if(s===r[0]&&i===r[1])return!0}return!1}createCountdownCanvas(){const e=document.createElement("canvas");e.width=this.canvasWidth,e.height=this.canvasHeight,e.style.position="absolute",e.style.transform="translate(-50%, -50%)";const t=e.getContext("2d");this.plateBackground?t.drawImage(this.plateBackground,0,0,this.canvasWidth,this.canvasHeight):(t.strokeStyle="rgba(0, 255, 0, 1)",t.lineWidth=1,t.strokeRect(0,0,this.canvasWidth,this.canvasHeight),t.fillStyle="rgba(0, 0, 0, 1)",t.fillRect(0,0,this.canvasWidth,this.canvasHeight)),this.view.container.appendChild(e);const a=document.createElement("canvas");return a.width=this.canvasWidth-10,a.height=this.canvasHeight-10,a.style.position="absolute",a.style.transform="translate(-50%, -50%)",this.view.container.appendChild(a),[e,a]}}exports.default=m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@arcgis/core/Basemap"),d=require("@arcgis/core/config"),L=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GeoJSONLayer"),x=require("@arcgis/core/layers/MapImageLayer"),I=require("@arcgis/core/layers/TileLayer"),S=require("@arcgis/core/layers/WebTileLayer"),R=require("@arcgis/core/Map"),H=require("@arcgis/core/views/MapView"),_=require("@arcgis/core/views/SceneView"),G=require("@turf/destination"),j=require("@turf/helpers"),B=require("./custom-layer/custom-wmts-layer.js");function b(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return e.default=c,Object.freeze(e)}const T=b(L),f=b(z),N=b(j);function q(c,e){return c&&(c.startsWith("http://")||c.startsWith("https://")?c:e+c)}class U{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){var u,y,v,M;this.mapConfig=e.mapConfig;const{container:t,markerClickCallback:s,mapClickCallback:n}=e;d.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,d.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,d.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const a=new R;if(((u=this.mapConfig)==null?void 0:u.mapOptions.mode.toLowerCase())==="2d"?(this.view=new H({map:a,container:t,...this.mapConfig.mapOptions}),this.view.on("drag",i=>{i.button===2&&i.stopPropagation()})):this.view=new _({map:a,container:t,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(y=this.mapConfig)==null?void 0:y.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1,featureNavigation:!0},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async i=>{var C,P;if(n){let o=i.mapPoint;o.spatialReference.isWebMercator&&(o=f.webMercatorToGeographic(o)),n([o.x,o.y],[i.screenPoint.x,i.screenPoint.y],i)}if(this.view.type==="3d"){const o=this.view.camera;if(this.view.spatialReference.isWebMercator){const p=f.webMercatorToGeographic(o.position),w={heading:o.heading,tilt:o.tilt,position:p.toJSON()};console.log(w),(C=navigator.clipboard)==null||C.writeText(JSON.stringify(w))}else console.log(o.toJSON());console.log(this.view.zoom,this.view.scale)}else{let o=this.view.center;this.view.spatialReference.isWebMercator&&(o=f.webMercatorToGeographic(o)),console.log({center:o.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const r=(P=(await this.view.hitTest(i)).results)==null?void 0:P.filter(o=>o.type==="graphic");r.length>0&&r.forEach(o=>{var w;const p=o.graphic;(w=p.attributes)!=null&&w.type&&s&&s(p.attributes.type,p.attributes.id,p.attributes,i)})}),(v=this.mapConfig)!=null&&v.baseLayers?this.mapConfig.baseLayers.forEach(i=>{const l=q(i.url,this.mapConfig.assetsRoot);switch(i.type.toLowerCase()){case"webTile".toLowerCase():{const r=new S({urlTemplate:l,...i.options});a.add(r);break}case"tile":{const r=new I({url:l,...i.options});a.add(r);break}case"customWMTS".toLowerCase():{const r=new B.default({urlTemplate:l,...i.options});a.add(r);break}case"mapImage".toLowerCase():{const r=new x({url:l,...i.options});a.add(r);break}case"arcgis":{const r=new k(i.options);a.basemap=r;break}case"feature":{const r=new W({url:l,...i.options});a.add(r);break}}}):a.basemap=new k({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(M=this.mapConfig)!=null&&M.hdLayers){const i=this.mapConfig.hdLayers.map(l=>new O({url:q(l.url,this.mapConfig.assetsRoot),...l.options,title:l.options.id}));a.addMany(i)}this.view.ui.remove("attribution"),await this.view.when();const m=this.mapConfig.camera;let h;if(this.view.type==="2d"){let i=this.view.center;this.view.spatialReference.isWebMercator&&(i=f.webMercatorToGeographic(i)),h={center:[i.x,i.y],zoom:this.view.zoom}}else{let i=this.view.camera.position;this.view.spatialReference.isWebMercator&&(i=f.webMercatorToGeographic(i)),h={position:i,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return m?m.home=h:this.mapConfig.camera={home:h},this.view}setLayerVisibility(e){const{id:t,visible:s}=e,n=this.view.map.findLayerById(t);return n?(n.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var t;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((t=e.target)==null?void 0:t.type){case"point":e.target=new g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const t=e.tilt||0,s=e.heading||0;if(t===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:s,tilt:0},{duration:(e.duration||2)*1e3});else{const n=Math.tan(t*Math.PI/180)*e.height,a=G(N.point(e.center),n,s+180,{units:"meters"});await this.view.goTo({position:{x:a.geometry.coordinates[0],y:a.geometry.coordinates[1],z:e.height},heading:s,tilt:t},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:t,duration:s=0}=e,{camera:n}=this.mapConfig;if(!n)return{status:-1,message:"未配置camera"};const a=n[t];return a?(await this.view.goTo(a,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,t){let s=0;const a=1e3/30,m=T.watch(()=>this.view.center,()=>{const h=this.transformPoints(e),u=Date.now();u-s>a&&(t(h),s=u)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,m),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(t=>{const s=new g.Point({x:t[0],y:t[1]}),n=this.view.toScreen(s);return[n.x,n.y]})}cancelCoordinateTransform(e){const t=this.watchHandleMap.get(e);t&&(t.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:t,max:s}=e;!t&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,n=>{t&&n<=t&&(this.view.zoom=t),s&&n>=s&&(this.view.zoom=s)}))}}exports.default=U;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("@arcgis/core/Basemap"),g=require("@arcgis/core/config"),L=require("@arcgis/core/core/reactiveUtils"),d=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GeoJSONLayer"),x=require("@arcgis/core/layers/IntegratedMesh3DTilesLayer"),I=require("@arcgis/core/layers/MapImageLayer"),S=require("@arcgis/core/layers/TileLayer"),R=require("@arcgis/core/layers/WebTileLayer"),H=require("@arcgis/core/Map"),_=require("@arcgis/core/views/MapView"),G=require("@arcgis/core/views/SceneView"),j=require("@turf/destination"),B=require("@turf/helpers"),N=require("./custom-layer/custom-wmts-layer.js");function b(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return e.default=c,Object.freeze(e)}const T=b(L),m=b(z),U=b(B);function q(c,e){return c&&(c.startsWith("http://")||c.startsWith("https://")?c:e+c)}class E{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){var u,y,v,M;this.mapConfig=e.mapConfig;const{container:t,markerClickCallback:s,mapClickCallback:n}=e;g.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,g.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,g.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const a=new H;if(((u=this.mapConfig)==null?void 0:u.mapOptions.mode.toLowerCase())==="2d"?(this.view=new _({map:a,container:t,...this.mapConfig.mapOptions}),this.view.on("drag",i=>{i.button===2&&i.stopPropagation()})):this.view=new G({map:a,container:t,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(y=this.mapConfig)==null?void 0:y.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1,featureNavigation:!0},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async i=>{var k,P;if(n){let o=i.mapPoint;o.spatialReference.isWebMercator&&(o=m.webMercatorToGeographic(o)),n([o.x,o.y],[i.screenPoint.x,i.screenPoint.y],i)}if(this.view.type==="3d"){const o=this.view.camera;if(this.view.spatialReference.isWebMercator){const p=m.webMercatorToGeographic(o.position),w={heading:o.heading,tilt:o.tilt,position:p.toJSON()};console.log(w),(k=navigator.clipboard)==null||k.writeText(JSON.stringify(w))}else console.log(o.toJSON());console.log(this.view.zoom,this.view.scale)}else{let o=this.view.center;this.view.spatialReference.isWebMercator&&(o=m.webMercatorToGeographic(o)),console.log({center:o.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const r=(P=(await this.view.hitTest(i)).results)==null?void 0:P.filter(o=>o.type==="graphic");r.length>0&&r.forEach(o=>{var w;const p=o.graphic;(w=p.attributes)!=null&&w.type&&s&&s(p.attributes.type,p.attributes.id,p.attributes,i)})}),(v=this.mapConfig)!=null&&v.baseLayers?this.mapConfig.baseLayers.forEach(i=>{const l=q(i.url,this.mapConfig.assetsRoot);switch(i.type.toLowerCase()){case"webTile".toLowerCase():{const r=new R({urlTemplate:l,...i.options});a.add(r);break}case"tile":{const r=new S({url:l,...i.options});a.add(r);break}case"customWMTS".toLowerCase():{const r=new N.default({urlTemplate:l,...i.options});a.add(r);break}case"mapImage".toLowerCase():{const r=new I({url:l,...i.options});a.add(r);break}case"arcgis":{const r=new C(i.options);a.basemap=r;break}case"feature":{const r=new W({url:l,...i.options});a.add(r);break}case"3dtiles":{const r=new x({url:l,...i.options});a.add(r);break}}}):a.basemap=new C({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(M=this.mapConfig)!=null&&M.hdLayers){const i=this.mapConfig.hdLayers.map(l=>new O({url:q(l.url,this.mapConfig.assetsRoot),...l.options,title:l.options.id}));a.addMany(i)}this.view.ui.remove("attribution"),await this.view.when();const f=this.mapConfig.camera;let h;if(this.view.type==="2d"){let i=this.view.center;this.view.spatialReference.isWebMercator&&(i=m.webMercatorToGeographic(i)),h={center:[i.x,i.y],zoom:this.view.zoom}}else{let i=this.view.camera.position;this.view.spatialReference.isWebMercator&&(i=m.webMercatorToGeographic(i)),h={position:i,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return f?f.home=h:this.mapConfig.camera={home:h},this.view}setLayerVisibility(e){const{id:t,visible:s}=e,n=this.view.map.findLayerById(t);return n?(n.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var t;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((t=e.target)==null?void 0:t.type){case"point":e.target=new d.Point(e.target);break;case"polyline":e.target=new d.Polyline(e.target);break;case"polygon":e.target=new d.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const t=e.tilt||0,s=e.heading||0;if(t===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:s,tilt:0},{duration:(e.duration||2)*1e3});else{const n=Math.tan(t*Math.PI/180)*e.height,a=j(U.point(e.center),n,s+180,{units:"meters"});await this.view.goTo({position:{x:a.geometry.coordinates[0],y:a.geometry.coordinates[1],z:e.height},heading:s,tilt:t},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:t,duration:s=0}=e,{camera:n}=this.mapConfig;if(!n)return{status:-1,message:"未配置camera"};const a=n[t];return a?(await this.view.goTo(a,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,t){let s=0;const a=1e3/30,f=T.watch(()=>this.view.center,()=>{const h=this.transformPoints(e),u=Date.now();u-s>a&&(t(h),s=u)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(t=>{const s=new d.Point({x:t[0],y:t[1]}),n=this.view.toScreen(s);return[n.x,n.y]})}cancelCoordinateTransform(e){const t=this.watchHandleMap.get(e);t&&(t.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:t,max:s}=e;!t&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,n=>{t&&n<=t&&(this.view.zoom=t),s&&n>=s&&(this.view.zoom=s)}))}}exports.default=E;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.221",
3
+ "version": "1.0.223",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [