gisviewer-vue3-arcgis 1.0.257 → 1.0.259

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.
@@ -242,7 +242,7 @@ class me {
242
242
  async setLayerVisibility(e) {
243
243
  const { id: i, visible: s } = e;
244
244
  if (i === "shanghai_district")
245
- return !this.detachmentLayerLoaded && e.visible ? await this.loadDetachmentLayer() : this.detachmentLayer.visible = s, { status: 0, message: "ok" };
245
+ return !this.detachmentLayerLoaded && e.visible ? await this.loadDetachmentLayer() : this.detachmentLayer && (this.detachmentLayer.visible = s), { status: 0, message: "ok" };
246
246
  {
247
247
  const a = this.view.map.findLayerById(i);
248
248
  return a ? (a.visible = s, { status: 0, message: "ok" }) : { status: -1, message: "未找到图层" };
@@ -2,7 +2,7 @@ import m from "@arcgis/core/Graphic";
2
2
  import v from "@arcgis/core/layers/FeatureLayer";
3
3
  import D from "../common-utils.mjs";
4
4
  import { subDistrictPointLayerOptions as I, subDistrictLineLayerOptions as z } from "./layer-symbol.mjs";
5
- class R {
5
+ class C {
6
6
  constructor(i) {
7
7
  this.roadConnections = [], this.view = i, this.subDistrictPointLayer = new v(
8
8
  I
@@ -216,7 +216,7 @@ class R {
216
216
  const s = await this.subDistrictLineLayer.queryFeatures();
217
217
  s.features.length > 0 && await this.subDistrictLineLayer.applyEdits({
218
218
  deleteFeatures: s.features
219
- }), this.subDistrictLineLayer.definitionExpression = "1=1", (e = this.clickHandler) == null || e.remove();
219
+ }), this.subDistrictLineLayer.definitionExpression = "1=1", this.roadConnections = [], (e = this.clickHandler) == null || e.remove();
220
220
  }
221
221
  setVisible(i) {
222
222
  this.showRoads({ type: "district", id: "" }), this.subDistrictPointLayer.visible = i, this.subDistrictLineLayer.visible = i;
@@ -388,5 +388,5 @@ class R {
388
388
  }
389
389
  }
390
390
  export {
391
- R as default
391
+ C as default
392
392
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),M=require("@arcgis/core/config"),W=require("@arcgis/core/core/reactiveUtils"),b=require("@arcgis/core/geometry"),C=require("@arcgis/core/geometry/support/webMercatorUtils"),T=require("@arcgis/core/Graphic"),I=require("@arcgis/core/layers/FeatureLayer"),G=require("@arcgis/core/layers/GeoJSONLayer"),O=require("@arcgis/core/layers/GroupLayer"),S=require("@arcgis/core/layers/IntegratedMesh3DTilesLayer"),x=require("@arcgis/core/layers/MapImageLayer"),_=require("@arcgis/core/layers/TileLayer"),j=require("@arcgis/core/layers/WebTileLayer"),H=require("@arcgis/core/layers/WMSLayer"),B=require("@arcgis/core/Map"),N=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),E=require("@turf/destination"),U=require("@turf/helpers"),A=require("@arcgis/core/layers/GraphicsLayer"),D=require("./custom-layer/custom-wmts-layer.js");function k(y){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(y){for(const i in y)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(y,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>y[i]})}}return e.default=y,Object.freeze(e)}const q=k(W),L=k(C),V=k(U);class J{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null,this.detachmentLayerLoaded=!1}processUrl(e){return e&&(e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("{{")?e.replace("{{geoServer}}",this.mapConfig.geoServer):this.mapConfig.assetsRoot+e)}async initialize(e){var p,w,g,m;this.mapConfig=e.mapConfig;const{container:i,markerClickCallback:s,mapClickCallback:a}=e;M.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,M.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,M.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const o=new B;((p=this.mapConfig)==null?void 0:p.mapOptions.mode.toLowerCase())==="2d"?(this.view=new N({map:o,container:i,...this.mapConfig.mapOptions}),this.view.on("drag",t=>{t.button===2&&t.stopPropagation()})):this.view=new R({map:o,container:i,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(w=this.mapConfig)==null?void 0:w.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 t=>{var l,v;if(a){let n=t.mapPoint;n.spatialReference.isWebMercator&&(n=L.webMercatorToGeographic(n)),a([n.x,n.y],[t.screenPoint.x,t.screenPoint.y],t)}if(this.view.type==="3d"){const n=this.view.camera;if(this.view.spatialReference.isWebMercator){const d=L.webMercatorToGeographic(n.position),f={heading:n.heading,tilt:n.tilt,position:d.toJSON()};console.log(f),(l=navigator.clipboard)==null||l.writeText(JSON.stringify(f))}else console.log(n.toJSON());console.log(this.view.zoom,this.view.scale)}else{let n=this.view.center;this.view.spatialReference.isWebMercator&&(n=L.webMercatorToGeographic(n)),console.log({center:n.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const c=(v=(await this.view.hitTest(t)).results)==null?void 0:v.filter(n=>n.type==="graphic");c.length>0&&c.forEach(n=>{var f;const d=n.graphic;(f=d.attributes)!=null&&f.type&&s&&s(d.attributes.type,d.attributes.id,d.attributes,t)})});{let t=0,r=!1;this.view.on("pointer-move",async c=>{var v;const l=performance.now();if(!(r||l-t<100)){t=l,r=!0;try{const d=(v=(await this.view.hitTest(c)).results)==null?void 0:v.some(z=>z.type==="graphic"),f=this.view.container;f&&(f.style.cursor=d?"pointer":"default")}finally{r=!1}}})}if(this.view.on("pointer-leave",()=>{const t=this.view.container;t&&(t.style.cursor="default")}),(g=this.mapConfig)!=null&&g.baseLayers?this.mapConfig.baseLayers.forEach(t=>{const r=this.processUrl(t.url);let c=null;switch(t.type.toLowerCase()){case"webTile".toLowerCase():{c=new j({urlTemplate:r,...t.options});break}case"tile":{c=new _({url:r,...t.options});break}case"customwmts".toLowerCase():{c=new D.default({urlTemplate:r,...t.options});break}case"mapimage".toLowerCase():{c=new x({url:r,...t.options});break}case"arcgis":{const l=new P(t.options);o.basemap=l;break}case"feature":{c=new I({url:r,...t.options});break}case"3dtiles":{c=new S({url:r,...t.options});break}case"wms":{c=new H({url:r,...t.options});break}}if(c)if(t.group){let l=o.findLayerById(t.group);l&&l.type==="group"?l.add(c):(l=new O({id:t.group,title:t.groupTitle,visibilityMode:"inherited",layers:[c],visible:t.groupVisible!==!1}),o.add(l))}else o.add(c)}):o.basemap=new P({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(m=this.mapConfig)!=null&&m.hdLayers){const t=this.mapConfig.hdLayers.map(r=>new G({url:this.processUrl(r.url),...r.options,title:r.options.id}));o.addMany(t)}this.view.ui.remove("attribution"),await this.view.when();const h=this.mapConfig.camera;let u;if(this.view.type==="2d"){let t=this.view.center;this.view.spatialReference.isWebMercator&&(t=L.webMercatorToGeographic(t)),u={center:[t.x,t.y],zoom:this.view.zoom}}else{let t=this.view.camera.position;this.view.spatialReference.isWebMercator&&(t=L.webMercatorToGeographic(t)),u={position:t,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return h?h.home=u:this.mapConfig.camera={home:u},this.view}async setLayerVisibility(e){const{id:i,visible:s}=e;if(i==="shanghai_district")return!this.detachmentLayerLoaded&&e.visible?await this.loadDetachmentLayer():this.detachmentLayer.visible=s,{status:0,message:"ok"};{const a=this.view.map.findLayerById(i);return a?(a.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type.toLowerCase()){case"point":e.target=new b.Point(e.target);break;case"polyline":e.target=new b.Polyline(e.target);break;case"polygon":e.target=new b.Polygon(e.target);break;case"multipoint":e.target=new b.Multipoint(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}setMapZoom(e){return this.view?(this.view.zoom=e.zoom,{status:0,message:"成功"}):{status:-1,message:"未初始化"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,s=e.heading||0;if(i===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 a=Math.tan(i*Math.PI/180)*e.height,o=E(V.point(e.center),a,s+180,{units:"meters"});await this.view.goTo({position:{x:o.geometry.coordinates[0],y:o.geometry.coordinates[1],z:e.height},heading:s,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:s=0}=e,{camera:a}=this.mapConfig;if(!a)return{status:-1,message:"未配置camera"};const o=a[i];return o?(await this.view.goTo(o,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let s=0;const o=1e3/30,h=q.watch(()=>this.view.center,()=>{const u=this.transformPoints(e),p=Date.now();p-s>o&&(i(u),s=p)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,h),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const s=new b.Point({x:i[0],y:i[1]}),a=this.view.toScreen(s);return[a.x,a.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:s}=e;!i&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=q.watch(()=>this.view.zoom,a=>{i&&a<=i&&(this.view.zoom=i),s&&a>=s&&(this.view.zoom=s)}))}async loadDetachmentLayer(){this.detachmentLayer=new A({id:"detachmentLayer",title:"支队图层",effect:void 0}),this.view.map.add(this.detachmentLayer);const e=this.mapConfig.baseLayers;if(!e)return;const i=e.find(s=>s.options.id==="shanghai_district");if(i)try{const a=await(await fetch("/GisViewerAssets/ShangHai/Layers/district.json")).json(),o=[],{renderer:h,labelingInfo:u}=i.options;a.features.forEach(p=>{const w=p.attributes.ZD_NAME;if(w!=="高架支队"){let g=new b.Polygon({rings:p.geometry.rings});g=C.webMercatorToGeographic(g);const m=new T({geometry:g,attributes:p.attributes});if(h){if(h.type==="simple")m.symbol=h.symbol;else if(h.type==="unique-value"){const t=m.getAttribute("OBJECTID"),r=h.uniqueValueInfos.find(c=>c.value==t);m.symbol=r?r.symbol:h.defaultSymbol}}else m.symbol={type:"simple-fill",color:[227,237,255,.4],outline:{color:[255,195,153],width:2}};if(o.push(m),u&&w!=="边防港航支队"&&w!=="机场支队"){const t=new T({geometry:g.centroid,symbol:{...u.symbol,text:w}});o.push(t)}}}),this.detachmentLayer.addMany(o),this.detachmentLayerLoaded=!0}catch(s){console.error("加载支队图层失败:",s);return}}}exports.default=J;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),M=require("@arcgis/core/config"),W=require("@arcgis/core/core/reactiveUtils"),b=require("@arcgis/core/geometry"),C=require("@arcgis/core/geometry/support/webMercatorUtils"),T=require("@arcgis/core/Graphic"),I=require("@arcgis/core/layers/FeatureLayer"),G=require("@arcgis/core/layers/GeoJSONLayer"),O=require("@arcgis/core/layers/GroupLayer"),S=require("@arcgis/core/layers/IntegratedMesh3DTilesLayer"),x=require("@arcgis/core/layers/MapImageLayer"),_=require("@arcgis/core/layers/TileLayer"),j=require("@arcgis/core/layers/WebTileLayer"),H=require("@arcgis/core/layers/WMSLayer"),B=require("@arcgis/core/Map"),N=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),E=require("@turf/destination"),U=require("@turf/helpers"),A=require("@arcgis/core/layers/GraphicsLayer"),D=require("./custom-layer/custom-wmts-layer.js");function k(y){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(y){for(const i in y)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(y,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>y[i]})}}return e.default=y,Object.freeze(e)}const q=k(W),L=k(C),V=k(U);class J{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null,this.detachmentLayerLoaded=!1}processUrl(e){return e&&(e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("{{")?e.replace("{{geoServer}}",this.mapConfig.geoServer):this.mapConfig.assetsRoot+e)}async initialize(e){var p,w,g,m;this.mapConfig=e.mapConfig;const{container:i,markerClickCallback:s,mapClickCallback:o}=e;M.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,M.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,M.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const a=new B;((p=this.mapConfig)==null?void 0:p.mapOptions.mode.toLowerCase())==="2d"?(this.view=new N({map:a,container:i,...this.mapConfig.mapOptions}),this.view.on("drag",t=>{t.button===2&&t.stopPropagation()})):this.view=new R({map:a,container:i,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(w=this.mapConfig)==null?void 0:w.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 t=>{var l,v;if(o){let n=t.mapPoint;n.spatialReference.isWebMercator&&(n=L.webMercatorToGeographic(n)),o([n.x,n.y],[t.screenPoint.x,t.screenPoint.y],t)}if(this.view.type==="3d"){const n=this.view.camera;if(this.view.spatialReference.isWebMercator){const d=L.webMercatorToGeographic(n.position),f={heading:n.heading,tilt:n.tilt,position:d.toJSON()};console.log(f),(l=navigator.clipboard)==null||l.writeText(JSON.stringify(f))}else console.log(n.toJSON());console.log(this.view.zoom,this.view.scale)}else{let n=this.view.center;this.view.spatialReference.isWebMercator&&(n=L.webMercatorToGeographic(n)),console.log({center:n.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const c=(v=(await this.view.hitTest(t)).results)==null?void 0:v.filter(n=>n.type==="graphic");c.length>0&&c.forEach(n=>{var f;const d=n.graphic;(f=d.attributes)!=null&&f.type&&s&&s(d.attributes.type,d.attributes.id,d.attributes,t)})});{let t=0,r=!1;this.view.on("pointer-move",async c=>{var v;const l=performance.now();if(!(r||l-t<100)){t=l,r=!0;try{const d=(v=(await this.view.hitTest(c)).results)==null?void 0:v.some(z=>z.type==="graphic"),f=this.view.container;f&&(f.style.cursor=d?"pointer":"default")}finally{r=!1}}})}if(this.view.on("pointer-leave",()=>{const t=this.view.container;t&&(t.style.cursor="default")}),(g=this.mapConfig)!=null&&g.baseLayers?this.mapConfig.baseLayers.forEach(t=>{const r=this.processUrl(t.url);let c=null;switch(t.type.toLowerCase()){case"webTile".toLowerCase():{c=new j({urlTemplate:r,...t.options});break}case"tile":{c=new _({url:r,...t.options});break}case"customwmts".toLowerCase():{c=new D.default({urlTemplate:r,...t.options});break}case"mapimage".toLowerCase():{c=new x({url:r,...t.options});break}case"arcgis":{const l=new P(t.options);a.basemap=l;break}case"feature":{c=new I({url:r,...t.options});break}case"3dtiles":{c=new S({url:r,...t.options});break}case"wms":{c=new H({url:r,...t.options});break}}if(c)if(t.group){let l=a.findLayerById(t.group);l&&l.type==="group"?l.add(c):(l=new O({id:t.group,title:t.groupTitle,visibilityMode:"inherited",layers:[c],visible:t.groupVisible!==!1}),a.add(l))}else a.add(c)}):a.basemap=new P({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(m=this.mapConfig)!=null&&m.hdLayers){const t=this.mapConfig.hdLayers.map(r=>new G({url:this.processUrl(r.url),...r.options,title:r.options.id}));a.addMany(t)}this.view.ui.remove("attribution"),await this.view.when();const h=this.mapConfig.camera;let u;if(this.view.type==="2d"){let t=this.view.center;this.view.spatialReference.isWebMercator&&(t=L.webMercatorToGeographic(t)),u={center:[t.x,t.y],zoom:this.view.zoom}}else{let t=this.view.camera.position;this.view.spatialReference.isWebMercator&&(t=L.webMercatorToGeographic(t)),u={position:t,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return h?h.home=u:this.mapConfig.camera={home:u},this.view}async setLayerVisibility(e){const{id:i,visible:s}=e;if(i==="shanghai_district")return!this.detachmentLayerLoaded&&e.visible?await this.loadDetachmentLayer():this.detachmentLayer&&(this.detachmentLayer.visible=s),{status:0,message:"ok"};{const o=this.view.map.findLayerById(i);return o?(o.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type.toLowerCase()){case"point":e.target=new b.Point(e.target);break;case"polyline":e.target=new b.Polyline(e.target);break;case"polygon":e.target=new b.Polygon(e.target);break;case"multipoint":e.target=new b.Multipoint(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}setMapZoom(e){return this.view?(this.view.zoom=e.zoom,{status:0,message:"成功"}):{status:-1,message:"未初始化"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,s=e.heading||0;if(i===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 o=Math.tan(i*Math.PI/180)*e.height,a=E(V.point(e.center),o,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:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:s=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const a=o[i];return a?(await this.view.goTo(a,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let s=0;const a=1e3/30,h=q.watch(()=>this.view.center,()=>{const u=this.transformPoints(e),p=Date.now();p-s>a&&(i(u),s=p)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,h),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const s=new b.Point({x:i[0],y:i[1]}),o=this.view.toScreen(s);return[o.x,o.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:s}=e;!i&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=q.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),s&&o>=s&&(this.view.zoom=s)}))}async loadDetachmentLayer(){this.detachmentLayer=new A({id:"detachmentLayer",title:"支队图层",effect:void 0}),this.view.map.add(this.detachmentLayer);const e=this.mapConfig.baseLayers;if(!e)return;const i=e.find(s=>s.options.id==="shanghai_district");if(i)try{const o=await(await fetch("/GisViewerAssets/ShangHai/Layers/district.json")).json(),a=[],{renderer:h,labelingInfo:u}=i.options;o.features.forEach(p=>{const w=p.attributes.ZD_NAME;if(w!=="高架支队"){let g=new b.Polygon({rings:p.geometry.rings});g=C.webMercatorToGeographic(g);const m=new T({geometry:g,attributes:p.attributes});if(h){if(h.type==="simple")m.symbol=h.symbol;else if(h.type==="unique-value"){const t=m.getAttribute("OBJECTID"),r=h.uniqueValueInfos.find(c=>c.value==t);m.symbol=r?r.symbol:h.defaultSymbol}}else m.symbol={type:"simple-fill",color:[227,237,255,.4],outline:{color:[255,195,153],width:2}};if(a.push(m),u&&w!=="边防港航支队"&&w!=="机场支队"){const t=new T({geometry:g.centroid,symbol:{...u.symbol,text:w}});a.push(t)}}}),this.detachmentLayer.addMany(a),this.detachmentLayerLoaded=!0}catch(s){console.error("加载支队图层失败:",s);return}}}exports.default=J;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@arcgis/core/Graphic"),m=require("@arcgis/core/layers/FeatureLayer"),D=require("../common-utils.js"),w=require("./layer-symbol.js");class g{constructor(e){this.roadConnections=[],this.view=e,this.subDistrictPointLayer=new m(w.subDistrictPointLayerOptions),this.subDistrictPointLayer.spatialReference=e.spatialReference,this.subDistrictPointLayer.popupEnabled=!0,this.subDistrictLineLayer=new m(w.subDistrictLineLayerOptions),this.subDistrictLineLayer.spatialReference=e.spatialReference,this.subDistrictLineLayer.popupEnabled=!0,this.view.map.addMany([this.subDistrictLineLayer,this.subDistrictPointLayer])}async showSubDistricts(e){var a;await this.clearSubDistricts(),(a=this.clickHandler)==null||a.remove(),this.clickHandler=this.view.on("click",this.viewHitTest.bind(this));let s=0;const i=[],r=[];e.forEach(t=>{t.roadConnections.length>0&&this.roadConnections.push(...t.roadConnections),r.push({value:t.id,label:t.name,symbol:{type:"simple-marker",style:"circle",color:[...t.areaColor,.8],size:"8px",outline:{color:[...t.areaColor],width:4}}}),t.signals.forEach(u=>{const d=new v({geometry:{type:"point",longitude:u.longitude,latitude:u.latitude},attributes:{ObjectID:s++,id:u.nodeId,name:u.name,subDistrictId:t.id,subDistrictName:t.name,districtId:t.parentId,districtName:t.parentName,signalCount:t.signalCount,color:t.areaColor.join(","),type:"subDistrict"}});i.push(d)})}),this.subDistrictPointLayer.renderer={type:"unique-value",field:"subDistrictId",defaultSymbol:{type:"simple-marker",color:[180,180,180,.5],size:"8px",outline:{color:"white",width:1}},defaultLabel:"其他子区",uniqueValueInfos:r,visualVariables:[{type:"size",valueExpression:"$view.scale",stops:[{size:24,value:2500},{size:20,value:5e3},{size:8,value:18055.954822000003},{size:4,value:144447.638572},{size:2,value:1155581108577e-6}]}]},this.currentPointRenderer=this.subDistrictPointLayer.renderer.clone(),await this.subDistrictPointLayer.applyEdits({addFeatures:i}),await D.default.viewGoto(this.view,i)}async showRoads(e){const{type:s,id:i}=e,r=this.subDistrictPointLayer.createQuery(),a=s==="district"?"districtId":"subDistrictId";i!==""?r.where=`${a} = '${i}'`:r.where="1=1";const t=await this.subDistrictPointLayer.queryFeatures(r),u=new Map;t.features.forEach(n=>{var p;const{subDistrictId:o,color:c,id:h,districtName:y,subDistrictName:L,signalCount:b}=n.attributes;u.has(o)||u.set(o,{color:c,signalIds:[],districtName:y,subDistrictName:L,signalCount:b}),(p=u.get(o))==null||p.signalIds.push(h)});const d=[],f=[];for(const n of u){let o=0;const c=n[0];d.push({value:c,symbol:{type:"simple-line",color:n[1].color.split(",").map(Number),width:2,style:"solid"}});const{districtName:h,subDistrictName:y,signalIds:L,signalCount:b}=n[1];this.roadConnections.filter(l=>l.subDistrictId===c).forEach(l=>{const I=new v({geometry:{type:"polyline",paths:l.coordinates},attributes:{ObjectID:o++,id:l.id,districtId:l.districtId,subDistrictId:c,subDistrictName:y,districtName:h,signalCount:b,color:n[1].color}});f.push(I)})}this.subDistrictLineLayer.renderer={type:"unique-value",field:"subDistrictId",defaultSymbol:{type:"simple-line",color:[180,180,180,.5],width:2,style:"solid"},defaultLabel:"其他子区",uniqueValueInfos:d,visualVariables:[{type:"size",valueExpression:"$view.scale",stops:[{size:6,value:2500},{size:5,value:5e3},{size:4,value:18055.954822000003},{size:3,value:144447.638572},{size:2,value:1155581108577e-6}]}]},this.currentLineRenderer=this.subDistrictLineLayer.renderer.clone(),await this.subDistrictLineLayer.applyEdits({addFeatures:f})}async clearSubDistricts(){var i;const e=await this.subDistrictPointLayer.queryFeatures();e.features.length>0&&await this.subDistrictPointLayer.applyEdits({deleteFeatures:e.features}),this.subDistrictPointLayer.definitionExpression="1=1";const s=await this.subDistrictLineLayer.queryFeatures();s.features.length>0&&await this.subDistrictLineLayer.applyEdits({deleteFeatures:s.features}),this.subDistrictLineLayer.definitionExpression="1=1",(i=this.clickHandler)==null||i.remove()}setVisible(e){this.showRoads({type:"district",id:""}),this.subDistrictPointLayer.visible=e,this.subDistrictLineLayer.visible=e}async locateSubDistrict(e){const s=this.subDistrictPointLayer.createQuery();s.where=`subDistrictId = '${e}'`,s.returnGeometry=!0;const i=await this.subDistrictPointLayer.queryFeatures(s);return i.features.length>0?(await D.default.viewGoto(this.view,i.features,!1),{status:0,message:"ok"}):{status:1,message:"未找到子区"}}async highlightSubDistrict(e){let s="";const i=this.subDistrictPointLayer.definitionExpression;this.subDistrictPointLayer.definitionExpression=`subDistrictId = '${e.id}'`;const r=await this.subDistrictPointLayer.queryFeatures(),a=r.features.length;return a>0?(this.subDistrictLineLayer.definitionExpression=`subDistrictId = '${e.id}'`,s=r.features[0].attributes.districtId,await D.default.viewGoto(this.view,r.features,e.needZoom!==!1)):this.subDistrictPointLayer.definitionExpression=i,{count:a,parentId:s}}filter(e){const{type:s,id:i}=e,r=`${s==="district"?"districtId":"subDistrictId"} = '${i}'`;this.subDistrictPointLayer.definitionExpression=r,this.subDistrictLineLayer.definitionExpression=r}resetFilter(){this.subDistrictPointLayer.definitionExpression="1=1",this.subDistrictLineLayer.definitionExpression="1=1"}async viewHitTest(e){var r;const i=(r=(await this.view.hitTest(e,{include:[this.subDistrictPointLayer,this.subDistrictLineLayer]})).results)==null?void 0:r.filter(a=>a.type==="graphic");if(i.length===0)console.time("resetRenderer"),this.subDistrictPointLayer.renderer=this.currentPointRenderer,this.subDistrictLineLayer.renderer=this.currentLineRenderer;else{const a=i[0].graphic,t=a.attributes.color.split(",").map(Number);this.subDistrictPointLayer.renderer={type:"unique-value",field:"subDistrictId",defaultSymbol:{type:"simple-marker",style:"circle",color:[0,0,0,0],size:"8px",outline:{color:[180,180,180,.5],width:4}},defaultLabel:"其他子区",uniqueValueInfos:[{value:a.attributes.subDistrictId,symbol:{type:"simple-marker",style:"circle",color:[...t,.8],size:"8px",outline:{color:t,width:4}}}],visualVariables:[{type:"size",valueExpression:"$view.scale",stops:[{size:24,value:2500},{size:20,value:5e3},{size:8,value:18055.954822000003},{size:4,value:144447.638572},{size:2,value:1155581108577e-6}]}]},this.subDistrictLineLayer.renderer={type:"unique-value",field:"subDistrictId",defaultSymbol:{type:"simple-line",style:"solid",color:[180,180,180,.5],width:"8px"},defaultLabel:"其他子区",uniqueValueInfos:[{value:a.attributes.subDistrictId,symbol:{type:"simple-line",style:"solid",color:a.attributes.color.split(",").map(Number),width:"8px"}}],visualVariables:[{type:"size",valueExpression:"$view.scale",stops:[{size:6,value:2500},{size:5,value:5e3},{size:4,value:18055.954822000003},{size:3,value:144447.638572},{size:2,value:1155581108577e-6}]}]}}}}exports.default=g;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@arcgis/core/Graphic"),m=require("@arcgis/core/layers/FeatureLayer"),D=require("../common-utils.js"),w=require("./layer-symbol.js");class g{constructor(e){this.roadConnections=[],this.view=e,this.subDistrictPointLayer=new m(w.subDistrictPointLayerOptions),this.subDistrictPointLayer.spatialReference=e.spatialReference,this.subDistrictPointLayer.popupEnabled=!0,this.subDistrictLineLayer=new m(w.subDistrictLineLayerOptions),this.subDistrictLineLayer.spatialReference=e.spatialReference,this.subDistrictLineLayer.popupEnabled=!0,this.view.map.addMany([this.subDistrictLineLayer,this.subDistrictPointLayer])}async showSubDistricts(e){var a;await this.clearSubDistricts(),(a=this.clickHandler)==null||a.remove(),this.clickHandler=this.view.on("click",this.viewHitTest.bind(this));let s=0;const i=[],r=[];e.forEach(t=>{t.roadConnections.length>0&&this.roadConnections.push(...t.roadConnections),r.push({value:t.id,label:t.name,symbol:{type:"simple-marker",style:"circle",color:[...t.areaColor,.8],size:"8px",outline:{color:[...t.areaColor],width:4}}}),t.signals.forEach(n=>{const d=new v({geometry:{type:"point",longitude:n.longitude,latitude:n.latitude},attributes:{ObjectID:s++,id:n.nodeId,name:n.name,subDistrictId:t.id,subDistrictName:t.name,districtId:t.parentId,districtName:t.parentName,signalCount:t.signalCount,color:t.areaColor.join(","),type:"subDistrict"}});i.push(d)})}),this.subDistrictPointLayer.renderer={type:"unique-value",field:"subDistrictId",defaultSymbol:{type:"simple-marker",color:[180,180,180,.5],size:"8px",outline:{color:"white",width:1}},defaultLabel:"其他子区",uniqueValueInfos:r,visualVariables:[{type:"size",valueExpression:"$view.scale",stops:[{size:24,value:2500},{size:20,value:5e3},{size:8,value:18055.954822000003},{size:4,value:144447.638572},{size:2,value:1155581108577e-6}]}]},this.currentPointRenderer=this.subDistrictPointLayer.renderer.clone(),await this.subDistrictPointLayer.applyEdits({addFeatures:i}),await D.default.viewGoto(this.view,i)}async showRoads(e){const{type:s,id:i}=e,r=this.subDistrictPointLayer.createQuery(),a=s==="district"?"districtId":"subDistrictId";i!==""?r.where=`${a} = '${i}'`:r.where="1=1";const t=await this.subDistrictPointLayer.queryFeatures(r),n=new Map;t.features.forEach(u=>{var p;const{subDistrictId:o,color:c,id:h,districtName:y,subDistrictName:L,signalCount:b}=u.attributes;n.has(o)||n.set(o,{color:c,signalIds:[],districtName:y,subDistrictName:L,signalCount:b}),(p=n.get(o))==null||p.signalIds.push(h)});const d=[],f=[];for(const u of n){let o=0;const c=u[0];d.push({value:c,symbol:{type:"simple-line",color:u[1].color.split(",").map(Number),width:2,style:"solid"}});const{districtName:h,subDistrictName:y,signalIds:L,signalCount:b}=u[1];this.roadConnections.filter(l=>l.subDistrictId===c).forEach(l=>{const I=new v({geometry:{type:"polyline",paths:l.coordinates},attributes:{ObjectID:o++,id:l.id,districtId:l.districtId,subDistrictId:c,subDistrictName:y,districtName:h,signalCount:b,color:u[1].color}});f.push(I)})}this.subDistrictLineLayer.renderer={type:"unique-value",field:"subDistrictId",defaultSymbol:{type:"simple-line",color:[180,180,180,.5],width:2,style:"solid"},defaultLabel:"其他子区",uniqueValueInfos:d,visualVariables:[{type:"size",valueExpression:"$view.scale",stops:[{size:6,value:2500},{size:5,value:5e3},{size:4,value:18055.954822000003},{size:3,value:144447.638572},{size:2,value:1155581108577e-6}]}]},this.currentLineRenderer=this.subDistrictLineLayer.renderer.clone(),await this.subDistrictLineLayer.applyEdits({addFeatures:f})}async clearSubDistricts(){var i;const e=await this.subDistrictPointLayer.queryFeatures();e.features.length>0&&await this.subDistrictPointLayer.applyEdits({deleteFeatures:e.features}),this.subDistrictPointLayer.definitionExpression="1=1";const s=await this.subDistrictLineLayer.queryFeatures();s.features.length>0&&await this.subDistrictLineLayer.applyEdits({deleteFeatures:s.features}),this.subDistrictLineLayer.definitionExpression="1=1",this.roadConnections=[],(i=this.clickHandler)==null||i.remove()}setVisible(e){this.showRoads({type:"district",id:""}),this.subDistrictPointLayer.visible=e,this.subDistrictLineLayer.visible=e}async locateSubDistrict(e){const s=this.subDistrictPointLayer.createQuery();s.where=`subDistrictId = '${e}'`,s.returnGeometry=!0;const i=await this.subDistrictPointLayer.queryFeatures(s);return i.features.length>0?(await D.default.viewGoto(this.view,i.features,!1),{status:0,message:"ok"}):{status:1,message:"未找到子区"}}async highlightSubDistrict(e){let s="";const i=this.subDistrictPointLayer.definitionExpression;this.subDistrictPointLayer.definitionExpression=`subDistrictId = '${e.id}'`;const r=await this.subDistrictPointLayer.queryFeatures(),a=r.features.length;return a>0?(this.subDistrictLineLayer.definitionExpression=`subDistrictId = '${e.id}'`,s=r.features[0].attributes.districtId,await D.default.viewGoto(this.view,r.features,e.needZoom!==!1)):this.subDistrictPointLayer.definitionExpression=i,{count:a,parentId:s}}filter(e){const{type:s,id:i}=e,r=`${s==="district"?"districtId":"subDistrictId"} = '${i}'`;this.subDistrictPointLayer.definitionExpression=r,this.subDistrictLineLayer.definitionExpression=r}resetFilter(){this.subDistrictPointLayer.definitionExpression="1=1",this.subDistrictLineLayer.definitionExpression="1=1"}async viewHitTest(e){var r;const i=(r=(await this.view.hitTest(e,{include:[this.subDistrictPointLayer,this.subDistrictLineLayer]})).results)==null?void 0:r.filter(a=>a.type==="graphic");if(i.length===0)console.time("resetRenderer"),this.subDistrictPointLayer.renderer=this.currentPointRenderer,this.subDistrictLineLayer.renderer=this.currentLineRenderer;else{const a=i[0].graphic,t=a.attributes.color.split(",").map(Number);this.subDistrictPointLayer.renderer={type:"unique-value",field:"subDistrictId",defaultSymbol:{type:"simple-marker",style:"circle",color:[0,0,0,0],size:"8px",outline:{color:[180,180,180,.5],width:4}},defaultLabel:"其他子区",uniqueValueInfos:[{value:a.attributes.subDistrictId,symbol:{type:"simple-marker",style:"circle",color:[...t,.8],size:"8px",outline:{color:t,width:4}}}],visualVariables:[{type:"size",valueExpression:"$view.scale",stops:[{size:24,value:2500},{size:20,value:5e3},{size:8,value:18055.954822000003},{size:4,value:144447.638572},{size:2,value:1155581108577e-6}]}]},this.subDistrictLineLayer.renderer={type:"unique-value",field:"subDistrictId",defaultSymbol:{type:"simple-line",style:"solid",color:[180,180,180,.5],width:"8px"},defaultLabel:"其他子区",uniqueValueInfos:[{value:a.attributes.subDistrictId,symbol:{type:"simple-line",style:"solid",color:a.attributes.color.split(",").map(Number),width:"8px"}}],visualVariables:[{type:"size",valueExpression:"$view.scale",stops:[{size:6,value:2500},{size:5,value:5e3},{size:4,value:18055.954822000003},{size:3,value:144447.638572},{size:2,value:1155581108577e-6}]}]}}}}exports.default=g;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.257",
3
+ "version": "1.0.259",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [