gis定位功实现 刷新页面 左侧菜单跟着刷新
Showing
5 changed files
with
51 additions
and
11 deletions
... | @@ -460,8 +460,8 @@ export default { | ... | @@ -460,8 +460,8 @@ export default { |
460 | //导出文本文件 | 460 | //导出文本文件 |
461 | exportText(){ | 461 | exportText(){ |
462 | var self = this; | 462 | var self = this; |
463 | var BSM = this.zdData.zdbsm; | ||
464 | var type = this.zdData.type; | 463 | var type = this.zdData.type; |
464 | var BSM = type == 'zdt'? this.zdData.zdbsm : this.zdData.bsm; | ||
465 | this.queryGeoByBsm(BSM,type,function (features){ | 465 | this.queryGeoByBsm(BSM,type,function (features){ |
466 | if(features && features.length > 0){ | 466 | if(features && features.length > 0){ |
467 | var data = features[0]; | 467 | var data = features[0]; |
... | @@ -489,8 +489,8 @@ export default { | ... | @@ -489,8 +489,8 @@ export default { |
489 | //导出shp文件 | 489 | //导出shp文件 |
490 | exportToShp(){ | 490 | exportToShp(){ |
491 | var self = this; | 491 | var self = this; |
492 | var BSM = this.zdData.zdbsm; | ||
493 | var type = this.zdData.type; | 492 | var type = this.zdData.type; |
493 | var BSM = type == 'zdt'? this.zdData.zdbsm : this.zdData.bsm; | ||
494 | this.queryGeoByBsm(BSM,type,function (features){ | 494 | this.queryGeoByBsm(BSM,type,function (features){ |
495 | if(features && features.length > 0){ | 495 | if(features && features.length > 0){ |
496 | var data = JSON.stringify(features[0]); | 496 | var data = JSON.stringify(features[0]); |
... | @@ -509,8 +509,8 @@ export default { | ... | @@ -509,8 +509,8 @@ export default { |
509 | //导出excel | 509 | //导出excel |
510 | exportExcel(){ | 510 | exportExcel(){ |
511 | var self = this; | 511 | var self = this; |
512 | var BSM = this.zdData.zdbsm; | ||
513 | var type = this.zdData.type; | 512 | var type = this.zdData.type; |
513 | var BSM = type == 'zdt'? this.zdData.zdbsm : this.zdData.bsm; | ||
514 | this.queryGeoByBsm(BSM,type,function (features) { | 514 | this.queryGeoByBsm(BSM,type,function (features) { |
515 | if (features && features.length > 0) { | 515 | if (features && features.length > 0) { |
516 | var data = features[0]; | 516 | var data = features[0]; |
... | @@ -549,6 +549,14 @@ export default { | ... | @@ -549,6 +549,14 @@ export default { |
549 | }, | 549 | }, |
550 | //图形定位 | 550 | //图形定位 |
551 | postionToMap(){ | 551 | postionToMap(){ |
552 | var type = this.zdData.type; | ||
553 | var BSM = type == 'zdt'? this.zdData.zdbsm : this.zdData.bsm; | ||
554 | if(this.$route.path == "/viewMap"){ | ||
555 | //定位到当前空间位置 | ||
556 | // TODO 这个方法只是为了支撑功能 | ||
557 | this.postionToThisGeo(BSM,type); | ||
558 | return; | ||
559 | } | ||
552 | var curretRouterInfo = { | 560 | var curretRouterInfo = { |
553 | path:this.$route.path, | 561 | path:this.$route.path, |
554 | query:this.$route.query | 562 | query:this.$route.query |
... | @@ -557,8 +565,8 @@ export default { | ... | @@ -557,8 +565,8 @@ export default { |
557 | this.$router.push({ | 565 | this.$router.push({ |
558 | path: "/viewMap", | 566 | path: "/viewMap", |
559 | query: { | 567 | query: { |
560 | bsm: this.zdData.zdbsm, | 568 | bsm: BSM, |
561 | type: this.zdData.type ? 'zd' : 'zrz' | 569 | type: type |
562 | } | 570 | } |
563 | }); | 571 | }); |
564 | }, | 572 | }, | ... | ... |
... | @@ -9,7 +9,7 @@ import {loadModules} from "esri-loader" | ... | @@ -9,7 +9,7 @@ import {loadModules} from "esri-loader" |
9 | import featureUpdate from "@libs/map/featureUpdate"; | 9 | import featureUpdate from "@libs/map/featureUpdate"; |
10 | import arcgisParser from 'terraformer-arcgis-parser' | 10 | import arcgisParser from 'terraformer-arcgis-parser' |
11 | import wktParse from 'terraformer-wkt-parser' | 11 | import wktParse from 'terraformer-wkt-parser' |
12 | 12 | import {maps} from '@/libs/map/mapUtils' | |
13 | 13 | ||
14 | export default { | 14 | export default { |
15 | data(){ | 15 | data(){ |
... | @@ -158,6 +158,18 @@ export default { | ... | @@ -158,6 +158,18 @@ export default { |
158 | }*/ | 158 | }*/ |
159 | return arcgisParser.convert(primitive) | 159 | return arcgisParser.convert(primitive) |
160 | }, | 160 | }, |
161 | postionToThisGeo(bsm,type){ | ||
162 | var view = maps["testMap"]; | ||
163 | var layer = view.map.findLayerById("highlightLayer"); | ||
164 | if(layer){ | ||
165 | var graphics = layer.graphics; | ||
166 | if(graphics.length > 0 && graphics.items[0].attributes.BSM == bsm){ | ||
167 | view.extent = graphics.items[0].geometry.extent; | ||
168 | } | ||
169 | }else { | ||
170 | this.$message.warning("暂无图形信息!!!"); | ||
171 | } | ||
172 | }, | ||
161 | //导入空间图形是 先判断数据是否跨界 | 173 | //导入空间图形是 先判断数据是否跨界 |
162 | geoJoint(geometry,callBacFunction){ | 174 | geoJoint(geometry,callBacFunction){ |
163 | var self = this; | 175 | var self = this; | ... | ... |
... | @@ -68,7 +68,8 @@ export default { | ... | @@ -68,7 +68,8 @@ export default { |
68 | }, | 68 | }, |
69 | provide(){ | 69 | provide(){ |
70 | return{ | 70 | return{ |
71 | getRightTree: this.getRightTree | 71 | getRightTree: this.getRightTree, |
72 | getRightTreeByZrzbsm:this.getRightTreeByZrzbsm | ||
72 | } | 73 | } |
73 | }, | 74 | }, |
74 | data() { | 75 | data() { | ... | ... |
... | @@ -56,6 +56,7 @@ import layers from '@/assets/json/layers.json' | ... | @@ -56,6 +56,7 @@ import layers from '@/assets/json/layers.json' |
56 | import findTask from '@/libs/map/findTask' | 56 | import findTask from '@/libs/map/findTask' |
57 | 57 | ||
58 | export default { | 58 | export default { |
59 | inject:['getRightTree','getRightTreeByZrzbsm'], | ||
59 | components:{ | 60 | components:{ |
60 | EsriMap, | 61 | EsriMap, |
61 | MapTools | 62 | MapTools |
... | @@ -75,10 +76,16 @@ export default { | ... | @@ -75,10 +76,16 @@ export default { |
75 | }, | 76 | }, |
76 | mixins:[mapLayerManager,findTask], | 77 | mixins:[mapLayerManager,findTask], |
77 | mounted(){ | 78 | mounted(){ |
78 | var query = this.$route.query; | 79 | var query = self.$route.query; |
79 | if(query && JSON.stringify(query) != "{}"){ | 80 | if(query && JSON.stringify(query) != "{}"){ |
80 | this.addGeoByBsm(query.bsm,query.type,this.viewId); | 81 | //self.addGeoByBsm(query.bsm,query.type,self.viewId); |
82 | if(query.type == 'zd'){ | ||
83 | this.getRightTree(query.bsm) | ||
84 | }else if(query.type == 'zrz'){ | ||
85 | this.getRightTreeByZrzbsm(query.bsm); | ||
81 | } | 86 | } |
87 | } | ||
88 | |||
82 | }, | 89 | }, |
83 | methods:{ | 90 | methods:{ |
84 | addLayer(){ | 91 | addLayer(){ |
... | @@ -108,6 +115,10 @@ export default { | ... | @@ -108,6 +115,10 @@ export default { |
108 | }] | 115 | }] |
109 | }); | 116 | }); |
110 | view.map.add(mapImageLayer,1); | 117 | view.map.add(mapImageLayer,1); |
118 | var query = self.$route.query; | ||
119 | if(query && JSON.stringify(query) != "{}"){ | ||
120 | self.addGeoByBsm(query.bsm,query.type,self.viewId); | ||
121 | } | ||
111 | }).catch(err => { | 122 | }).catch(err => { |
112 | throw(err); | 123 | throw(err); |
113 | }) | 124 | }) |
... | @@ -115,9 +126,14 @@ export default { | ... | @@ -115,9 +126,14 @@ export default { |
115 | //缩放至 | 126 | //缩放至 |
116 | toMap(attr){ | 127 | toMap(attr){ |
117 | var self = this; | 128 | var self = this; |
129 | if(attr.geometry){ | ||
118 | this.extentToGraphic(attr,this.heighGraphic,this.viewId,function () { | 130 | this.extentToGraphic(attr,this.heighGraphic,this.viewId,function () { |
119 | self.heighGraphic = attr; | 131 | self.heighGraphic = attr; |
120 | }); | 132 | }); |
133 | }else { | ||
134 | this.$message.warning("没有图形信息!!") | ||
135 | } | ||
136 | |||
121 | }, | 137 | }, |
122 | //图层选择事件 | 138 | //图层选择事件 |
123 | selectLayerChange(){ | 139 | selectLayerChange(){ | ... | ... |
... | @@ -56,7 +56,7 @@ export default { | ... | @@ -56,7 +56,7 @@ export default { |
56 | var graphic = features[0]; | 56 | var graphic = features[0]; |
57 | graphic.symbol = symbol; | 57 | graphic.symbol = symbol; |
58 | layer.add(graphic); | 58 | layer.add(graphic); |
59 | view.center = graphic.geometry.extent.center; | 59 | view.extent = graphic.geometry.extent; |
60 | }).catch( err => { | 60 | }).catch( err => { |
61 | thow(err); | 61 | thow(err); |
62 | }) | 62 | }) |
... | @@ -91,9 +91,12 @@ export default { | ... | @@ -91,9 +91,12 @@ export default { |
91 | var symbol = graphicSymbol.fillSymbol.highlightSymbol; | 91 | var symbol = graphicSymbol.fillSymbol.highlightSymbol; |
92 | var features = searchResult[i].features; | 92 | var features = searchResult[i].features; |
93 | for(var j = 0;j < features.length;j++){ | 93 | for(var j = 0;j < features.length;j++){ |
94 | if(features[j].geometry){ | ||
94 | features[j].symbol = symbol; | 95 | features[j].symbol = symbol; |
95 | layer.add(features[j]); | 96 | layer.add(features[j]); |
96 | } | 97 | } |
98 | |||
99 | } | ||
97 | } | 100 | } |
98 | }).catch(err=>{ | 101 | }).catch(err=>{ |
99 | console.log(err); | 102 | console.log(err); |
... | @@ -108,7 +111,7 @@ export default { | ... | @@ -108,7 +111,7 @@ export default { |
108 | } | 111 | } |
109 | feature.symbol = highlightSymbol; | 112 | feature.symbol = highlightSymbol; |
110 | var view = maps[viewId]; | 113 | var view = maps[viewId]; |
111 | view.center = feature.geometry.type == 'point' ? feature.geometry : feature.geometry.extent.center; | 114 | feature.geometry.type == 'point' ?view.center = feature.geometry :view.extent = feature.geometry.extent; |
112 | if(callBackFunction && typeof callBackFunction == 'function'){ | 115 | if(callBackFunction && typeof callBackFunction == 'function'){ |
113 | callBackFunction(); | 116 | callBackFunction(); |
114 | } | 117 | } | ... | ... |
-
Please register or sign in to post a comment