Commit 6957b6d0 authored by yaqizhang's avatar yaqizhang

Merge branch 'master' of ssh://111.61.77.35:15/lizhichao/whp-xl into master

parents 7d45bda3 e225d429
...@@ -316,39 +316,14 @@ export default class Mutil { ...@@ -316,39 +316,14 @@ export default class Mutil {
} }
drawArea(json) { drawArea(json) {
let pointsz = []; //存储点坐标 if(json.polyline.indexOf("|")!=-1){
let points = json.polyline.split(";"); //获取点坐标 let bundaries = json.polyline.split("|");
//对获取的点坐标数据进行处理,重构,得到我们需要的数据结构 for(let j=0;j < bundaries.length;j++){
for (let i = 0; i < points.length; i++) { this.combineDrawAreas(bundaries[j]);
let region = points[i]; //单个面 }
let pArr = region.split(','); }else{
let pos = fromLonLat(pArr); //将坐标转为默认投影,默认投影是EPSG:3857 this.combineDrawAreas(json.polyline);
//let hdms = transform(pos, 'EPSG:3857', 'EPSG:4326'); //坐标系间坐标转换,由前面的坐标转为后面坐标系坐标
pointsz.push(pos) //将转化格式后的点坐标存储起来
};
//自己造的地图数据(GeoJSON数据)
let geojsonObject = this.structureGeojson(pointsz);
let vectorSource = new VectorSource({ //提供矢量图层的数据
features: (new GeoJSON().readFeatures(geojsonObject))
});
let vectorLayer = new VectorLayer({
source: vectorSource, //来源
style: new Style({
stroke: new Stroke({
color: '#08d527',
width: 4
}),
fill: new Fill({
color: 'rgba(212, 220, 29, 0.1)'
})
})
});
if (this.tempLayer != ' ') {
this.MAP.removeLayer(this.tempLayer);
} }
this.MAP.addLayer(vectorLayer);
this.tempLayer = vectorLayer;
} }
structureGeojson(pointsz){ structureGeojson(pointsz){
let geojsonObject = { let geojsonObject = {
...@@ -382,4 +357,40 @@ export default class Mutil { ...@@ -382,4 +357,40 @@ export default class Mutil {
this.drawArea(res.data.districts[0]) this.drawArea(res.data.districts[0])
}) })
} }
combineDrawAreas(json){
let pointsz = []; //存储点坐标
let points = json.split(";"); //获取点坐标
//对获取的点坐标数据进行处理,重构,得到我们需要的数据结构
for (let i = 0; i < points.length; i++) {
let region = points[i]; //单个面
let pArr = region.split(',');
let pos = fromLonLat(pArr); //将坐标转为默认投影,默认投影是EPSG:3857
//let hdms = transform(pos, 'EPSG:3857', 'EPSG:4326'); //坐标系间坐标转换,由前面的坐标转为后面坐标系坐标
pointsz.push(pos) //将转化格式后的点坐标存储起来
};
//自己造的地图数据(GeoJSON数据)
let geojsonObject = this.structureGeojson(pointsz);
let vectorSource = new VectorSource({ //提供矢量图层的数据
features: (new GeoJSON().readFeatures(geojsonObject))
});
let vectorLayer = new VectorLayer({
source: vectorSource, //来源
style: new Style({
stroke: new Stroke({
color: '#08d527',
width: 4
}),
fill: new Fill({
color: 'rgba(212, 220, 29, 0.1)'
})
})
});
/*if (this.tempLayer != ' ') {
this.MAP.removeLayer(this.tempLayer);
}*/
this.MAP.addLayer(vectorLayer);
//this.tempLayer = vectorLayer;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment