93e929f8 by 杨威

gis定位功实现 刷新页面 左侧菜单跟着刷新

1 parent 6f4675db
......@@ -460,8 +460,8 @@ export default {
//导出文本文件
exportText(){
var self = this;
var BSM = this.zdData.zdbsm;
var type = this.zdData.type;
var BSM = type == 'zdt'? this.zdData.zdbsm : this.zdData.bsm;
this.queryGeoByBsm(BSM,type,function (features){
if(features && features.length > 0){
var data = features[0];
......@@ -489,8 +489,8 @@ export default {
//导出shp文件
exportToShp(){
var self = this;
var BSM = this.zdData.zdbsm;
var type = this.zdData.type;
var BSM = type == 'zdt'? this.zdData.zdbsm : this.zdData.bsm;
this.queryGeoByBsm(BSM,type,function (features){
if(features && features.length > 0){
var data = JSON.stringify(features[0]);
......@@ -509,8 +509,8 @@ export default {
//导出excel
exportExcel(){
var self = this;
var BSM = this.zdData.zdbsm;
var type = this.zdData.type;
var BSM = type == 'zdt'? this.zdData.zdbsm : this.zdData.bsm;
this.queryGeoByBsm(BSM,type,function (features) {
if (features && features.length > 0) {
var data = features[0];
......@@ -549,6 +549,14 @@ export default {
},
//图形定位
postionToMap(){
var type = this.zdData.type;
var BSM = type == 'zdt'? this.zdData.zdbsm : this.zdData.bsm;
if(this.$route.path == "/viewMap"){
//定位到当前空间位置
// TODO 这个方法只是为了支撑功能
this.postionToThisGeo(BSM,type);
return;
}
var curretRouterInfo = {
path:this.$route.path,
query:this.$route.query
......@@ -557,8 +565,8 @@ export default {
this.$router.push({
path: "/viewMap",
query: {
bsm: this.zdData.zdbsm,
type: this.zdData.type ? 'zd' : 'zrz'
bsm: BSM,
type: type
}
});
},
......
......@@ -9,7 +9,7 @@ import {loadModules} from "esri-loader"
import featureUpdate from "@libs/map/featureUpdate";
import arcgisParser from 'terraformer-arcgis-parser'
import wktParse from 'terraformer-wkt-parser'
import {maps} from '@/libs/map/mapUtils'
export default {
data(){
......@@ -158,6 +158,18 @@ export default {
}*/
return arcgisParser.convert(primitive)
},
postionToThisGeo(bsm,type){
var view = maps["testMap"];
var layer = view.map.findLayerById("highlightLayer");
if(layer){
var graphics = layer.graphics;
if(graphics.length > 0 && graphics.items[0].attributes.BSM == bsm){
view.extent = graphics.items[0].geometry.extent;
}
}else {
this.$message.warning("暂无图形信息!!!");
}
},
//导入空间图形是 先判断数据是否跨界
geoJoint(geometry,callBacFunction){
var self = this;
......
......@@ -68,7 +68,8 @@ export default {
},
provide(){
return{
getRightTree: this.getRightTree
getRightTree: this.getRightTree,
getRightTreeByZrzbsm:this.getRightTreeByZrzbsm
}
},
data() {
......
......@@ -56,6 +56,7 @@ import layers from '@/assets/json/layers.json'
import findTask from '@/libs/map/findTask'
export default {
inject:['getRightTree','getRightTreeByZrzbsm'],
components:{
EsriMap,
MapTools
......@@ -75,10 +76,16 @@ export default {
},
mixins:[mapLayerManager,findTask],
mounted(){
var query = this.$route.query;
if(query && JSON.stringify(query) != "{}"){
this.addGeoByBsm(query.bsm,query.type,this.viewId);
}
var query = self.$route.query;
if(query && JSON.stringify(query) != "{}"){
//self.addGeoByBsm(query.bsm,query.type,self.viewId);
if(query.type == 'zd'){
this.getRightTree(query.bsm)
}else if(query.type == 'zrz'){
this.getRightTreeByZrzbsm(query.bsm);
}
}
},
methods:{
addLayer(){
......@@ -108,6 +115,10 @@ export default {
}]
});
view.map.add(mapImageLayer,1);
var query = self.$route.query;
if(query && JSON.stringify(query) != "{}"){
self.addGeoByBsm(query.bsm,query.type,self.viewId);
}
}).catch(err => {
throw(err);
})
......@@ -115,9 +126,14 @@ export default {
//缩放至
toMap(attr){
var self = this;
this.extentToGraphic(attr,this.heighGraphic,this.viewId,function () {
self.heighGraphic = attr;
});
if(attr.geometry){
this.extentToGraphic(attr,this.heighGraphic,this.viewId,function () {
self.heighGraphic = attr;
});
}else {
this.$message.warning("没有图形信息!!")
}
},
//图层选择事件
selectLayerChange(){
......
......@@ -56,7 +56,7 @@ export default {
var graphic = features[0];
graphic.symbol = symbol;
layer.add(graphic);
view.center = graphic.geometry.extent.center;
view.extent = graphic.geometry.extent;
}).catch( err => {
thow(err);
})
......@@ -91,8 +91,11 @@ export default {
var symbol = graphicSymbol.fillSymbol.highlightSymbol;
var features = searchResult[i].features;
for(var j = 0;j < features.length;j++){
features[j].symbol = symbol;
layer.add(features[j]);
if(features[j].geometry){
features[j].symbol = symbol;
layer.add(features[j]);
}
}
}
}).catch(err=>{
......@@ -108,7 +111,7 @@ export default {
}
feature.symbol = highlightSymbol;
var view = maps[viewId];
view.center = feature.geometry.type == 'point' ? feature.geometry : feature.geometry.extent.center;
feature.geometry.type == 'point' ?view.center = feature.geometry :view.extent = feature.geometry.extent;
if(callBackFunction && typeof callBackFunction == 'function'){
callBackFunction();
}
......