|
|
@@ -2,9 +2,6 @@
|
|
|
<template>
|
|
|
<div class="mapbox">
|
|
|
<div id="container"></div>
|
|
|
- <!-- <div id="map" v-loading="loading" v-show="canvasdisplay">
|
|
|
- <div class="mapdel" @click="canvasdisplay = false">×</div>
|
|
|
- </div> -->
|
|
|
<div id="mapbox">
|
|
|
<div id="map" v-loading="loading" v-show="canvasdisplay">
|
|
|
<!-- <div class="mapdel" @click="addInteraction">划分地块</div> -->
|
|
|
@@ -14,7 +11,7 @@
|
|
|
</div>
|
|
|
<div class="listBox">
|
|
|
<div class="projectSearch">
|
|
|
- <div>项目列表</div>
|
|
|
+ <div>基地列表</div>
|
|
|
<div>
|
|
|
<el-input
|
|
|
size="small"
|
|
|
@@ -80,7 +77,7 @@ export default {
|
|
|
//这里存放数据
|
|
|
return {
|
|
|
canvasdisplay: true,
|
|
|
- loading: true,
|
|
|
+ loading: false,
|
|
|
map: null,
|
|
|
input: "",
|
|
|
mapData: [
|
|
|
@@ -135,24 +132,24 @@ export default {
|
|
|
device_id: "866193059738670",
|
|
|
},
|
|
|
], //设备点定位
|
|
|
- Basename: "yunfei:result", //贴图名称
|
|
|
- basemap: [
|
|
|
- //贴图地图
|
|
|
- 12654161.262852993, 4138228.39035618, 12654499.539666895,
|
|
|
- 4138560.780442763,
|
|
|
- ],
|
|
|
+ Basename: "yunfei:beisanhuan", //贴图名称
|
|
|
+ // basemap: [
|
|
|
+ // //贴图地图
|
|
|
+ // 12654161.262852993, 4138228.39035618, 12654499.539666895,
|
|
|
+ // 4138560.780442763,
|
|
|
+ // ],
|
|
|
+ basemap: [12654161.262852995, 4138228.39035618,12654499.539666897, 4138560.780442763]
|
|
|
},
|
|
|
{
|
|
|
- projectname: "河南省小麦长势遥感图",
|
|
|
+ projectname: "河南省开封市尉氏县基地",
|
|
|
uuid: 3,
|
|
|
- latlng: [113.681471, 34.810371], //基地定位
|
|
|
+ latlng: [114.19284,34.41223], //基地定位
|
|
|
Baselocation: [],
|
|
|
equipmentlocation: [], //设备点定位
|
|
|
- Basename: "yunfei:xiaomaizhangshi", //贴图名称
|
|
|
+ Basename: "yunfei:weishi", //贴图名称
|
|
|
basemap: [
|
|
|
//贴图地图
|
|
|
- 12264222.56268119, 3671219.7387323463, 13021605.592033587,
|
|
|
- 4377641.963339285,
|
|
|
+ 12720250.438352395,4077648.4271950293,12722174.052177684,4079390.7616211823
|
|
|
],
|
|
|
},
|
|
|
],
|
|
|
@@ -174,129 +171,9 @@ export default {
|
|
|
watch: {},
|
|
|
//方法集合
|
|
|
methods: {
|
|
|
- initmap(item) {
|
|
|
- this.map = new AMap.Map("container", {
|
|
|
- resizeEnable: true,
|
|
|
- expandZoomRange: true,
|
|
|
- center: item.latlng, //中心点
|
|
|
- zoom: 16, //初始化缩放等级
|
|
|
- zooms: [3, 24], //设置最大、最小缩放等级
|
|
|
- layers: [new AMap.TileLayer.Satellite()], //加载卫星图
|
|
|
- });
|
|
|
- this.map.on("click", (e) => {
|
|
|
- console.log(e.lnglat);
|
|
|
- // var arr = [e.lnglat.lng, e.lnglat.lat];
|
|
|
- // this.addmarker(e.lnglat.lng, e.lnglat.lat);
|
|
|
- // this.path.push(arr);
|
|
|
- });
|
|
|
- // this.addpolygon(item.Baselocation);
|
|
|
- // this.addmarker();
|
|
|
- // this.addWMSLayer();
|
|
|
- },
|
|
|
- addpolygon(path) {
|
|
|
- var polygon = new AMap.Polygon({
|
|
|
- path: path,
|
|
|
- strokeColor: "#FF33FF", //外围边框颜色
|
|
|
- strokeWeight: 6,
|
|
|
- strokeOpacity: 0.2,
|
|
|
- fillOpacity: 0.4,
|
|
|
- fillColor: "#1791fc", //内部颜色
|
|
|
- zIndex: 50,
|
|
|
- });
|
|
|
- polygon.on("click", (e) => {
|
|
|
- this.canvasdisplay = true;
|
|
|
- console.log(e);
|
|
|
- });
|
|
|
- this.polygon = polygon;
|
|
|
- this.map.add(polygon);
|
|
|
- // 缩放地图到合适的视野级别
|
|
|
- // this.map.setFitView([polygon]);
|
|
|
- },
|
|
|
- addmarker() {
|
|
|
- var marker = new AMap.Marker({
|
|
|
- icon: "../../../../static/images/jidi2.png",
|
|
|
- position: [113.68258608341216, 34.811427520353476],
|
|
|
- });
|
|
|
- marker.on("click", (e) => {
|
|
|
- this.dialogbaseinfo = true;
|
|
|
- // this.canvasdisplay = true;
|
|
|
- });
|
|
|
- // marker.setMap(this.map);
|
|
|
- this.map.add(marker);
|
|
|
- // this.marker = marker
|
|
|
- // this.markers.push(marker);
|
|
|
- },
|
|
|
- tile2lon(x, z) {
|
|
|
- return (x / Math.pow(2, z)) * 360 - 180;
|
|
|
- },
|
|
|
- // 切片转纬度
|
|
|
- tile2lat(y, z) {
|
|
|
- var n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z);
|
|
|
- return (180 / Math.PI) * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
|
|
- },
|
|
|
- addWMSLayer() {
|
|
|
- var that = this;
|
|
|
- var resolutions = [];
|
|
|
- for (var i = 0; i < 19; i++) {
|
|
|
- resolutions[i] = Math.pow(2, 18 - i);
|
|
|
- }
|
|
|
- var tileLayer = new AMap.TileLayer({
|
|
|
- tileSize: 256,
|
|
|
- tileUrl: function (x, y, z) {
|
|
|
- let xmin = that.tile2lon(x, z);
|
|
|
- let xmax = that.tile2lon(x + 1, z);
|
|
|
- let ymin = that.tile2lat(y + 1, z);
|
|
|
- let ymax = that.tile2lat(y, z);
|
|
|
- // console.log(xmin, ymin)
|
|
|
- // 转换对应坐标
|
|
|
- // console.log(xmin, ymin);
|
|
|
- // console.log(xmax, ymax);
|
|
|
- let t1 = gcoord.transform(
|
|
|
- [xmin, ymin],
|
|
|
- gcoord.GCJ02,
|
|
|
- gcoord.EPSG3857
|
|
|
- );
|
|
|
- let t2 = gcoord.transform(
|
|
|
- [xmax, ymax],
|
|
|
- gcoord.GCJ02,
|
|
|
- gcoord.EPSG3857
|
|
|
- );
|
|
|
- // console.log(t1,t2)
|
|
|
- // 查询对象
|
|
|
- let url = "http://8.136.98.49:18080/geoserver/yunfei/wms?";
|
|
|
- let params = {
|
|
|
- service: "WMS",
|
|
|
- version: "1.1.0",
|
|
|
- transparent: true,
|
|
|
- request: "GetMap",
|
|
|
- layers: "yunfei:result",
|
|
|
- width: 769,
|
|
|
- height: 620,
|
|
|
- srs: "EPSG:3857",
|
|
|
- format: "image/png",
|
|
|
- bbox: [t1[0], t1[1], t2[0], t2[1]].join(","),
|
|
|
- };
|
|
|
- // 构建查询字符串
|
|
|
- let str = that.objToParams(params);
|
|
|
-
|
|
|
- return url + str;
|
|
|
- },
|
|
|
- zIndex: 10,
|
|
|
- });
|
|
|
- this.map.add(tileLayer);
|
|
|
- },
|
|
|
- objToParams(obj) {
|
|
|
- return Object.keys(obj)
|
|
|
- .map(function (key) {
|
|
|
- return ""
|
|
|
- .concat(encodeURIComponent(key), "=")
|
|
|
- .concat(encodeURIComponent(obj[key]));
|
|
|
- })
|
|
|
- .join("&");
|
|
|
- },
|
|
|
init(basedetails) {
|
|
|
// ol-viewport
|
|
|
- var gridsetName = "EPSG:900999";
|
|
|
+ var gridsetName = "EPSG:900999256";
|
|
|
var gridNames = [
|
|
|
"0",
|
|
|
"1",
|
|
|
@@ -341,16 +218,16 @@ export default {
|
|
|
axisOrientation: "neu",
|
|
|
});
|
|
|
var resolutions = [
|
|
|
- 1252344.27125, 626172.135625, 313086.0678125, 156543.03390625,
|
|
|
- 78271.516953125, 39135.7584765625, 19567.87923828125, 9783.939619140625,
|
|
|
- 4891.9698095703125, 2445.9849047851562, 1222.9924523925781,
|
|
|
- 611.4962261962891, 305.74811309814453, 152.87405654907226,
|
|
|
- 76.43702827453613, 38.218514137268066, 19.109257068634033,
|
|
|
- 9.554628534317017, 4.777314267158508, 2.388657133579254,
|
|
|
- 1.194328566789627, 0.5971642833948135, 0.2985821416974068,
|
|
|
- 0.1492910708487034, 0.0746455354243517, 0.0373227677121758,
|
|
|
- 0.0186613838560879, 0.009330691928044, 0.004665345964022,
|
|
|
- 0.002332672982011, 0.0011663364910055,
|
|
|
+ 156543.03390625, 78271.516953125, 39135.7584765625, 19567.87923828125,
|
|
|
+ 9783.939619140625, 4891.9698095703125, 2445.9849047851562,
|
|
|
+ 1222.9924523925781, 611.4962261962891, 305.74811309814453,
|
|
|
+ 152.87405654907226, 76.43702827453613, 38.218514137268066,
|
|
|
+ 19.109257068634033, 9.554628534317017, 4.777314267158508,
|
|
|
+ 2.388657133579254, 1.194328566789627, 0.5971642833948135,
|
|
|
+ 0.2985821416974068, 0.1492910708487034, 0.0746455354243517,
|
|
|
+ 0.0373227677121758, 0.0186613838560879, 0.009330691928044,
|
|
|
+ 0.004665345964022, 0.002332672982011, 0.0011663364910055,
|
|
|
+ 5.831682455027e-4, 2.915841227514e-4, 1.457920613757e-4,
|
|
|
];
|
|
|
var baseParams = [
|
|
|
"VERSION",
|
|
|
@@ -388,7 +265,7 @@ export default {
|
|
|
format: params["FORMAT"],
|
|
|
projection: projection,
|
|
|
tileGrid: new ol.tilegrid.WMTS({
|
|
|
- tileSize: [32, 32],
|
|
|
+ tileSize: [256, 256],
|
|
|
extent: [
|
|
|
-2.003750834e7, -2.003750834e7, 2.003750834e7, 2.003750834e7,
|
|
|
],
|
|
|
@@ -631,7 +508,6 @@ export default {
|
|
|
var l3 = new ol.layer.Tile({
|
|
|
source: new ol.source.XYZ({
|
|
|
url: "http://t3.tianditu.com/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=6e5cb1bfc017afcac7a21836cf81a884", // 地图
|
|
|
- cacheSize: [64, 64],
|
|
|
}),
|
|
|
});
|
|
|
var l4 = new ol.layer.Tile({
|
|
|
@@ -662,10 +538,12 @@ export default {
|
|
|
(event) => {
|
|
|
// style.getStroke().setColor("green");
|
|
|
// statusElement.innerHTML = " 一个要素被选中了!";
|
|
|
- console.log(event.H);
|
|
|
- this.deviceinfo = event.H.population;
|
|
|
- this.cityanalysis(this.deviceinfo.location);
|
|
|
- this.dialogbaseinfo = true;
|
|
|
+ console.log(event.H.population);
|
|
|
+ if (event.H.population) {
|
|
|
+ this.deviceinfo = event.H.population;
|
|
|
+ this.cityanalysis(this.deviceinfo.location);
|
|
|
+ this.dialogbaseinfo = true;
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
hitTolerance: 1,
|
|
|
@@ -674,10 +552,14 @@ export default {
|
|
|
});
|
|
|
var canbox = document.getElementsByClassName("ol-viewport");
|
|
|
// mapbox.removeChild(canbox)
|
|
|
- for (var i = 0; i < canbox.length; i++) {
|
|
|
- canbox[i].style.display = "none";
|
|
|
- canbox[canbox.length - 1].style.display = "block";
|
|
|
+ var fatherbox = document.getElementById("map");
|
|
|
+ if (canbox.length > 1) {
|
|
|
+ fatherbox.removeChild(canbox[0]);
|
|
|
}
|
|
|
+ // for (var i = 0; i < canbox.length; i++) {
|
|
|
+ // canbox[i].style.display = "none";
|
|
|
+ // canbox[canbox.length - 1].style.display = "block";
|
|
|
+ // }
|
|
|
},
|
|
|
//基地搜索
|
|
|
getEquipList() {},
|
|
|
@@ -685,10 +567,6 @@ export default {
|
|
|
equipLocate(item, index) {
|
|
|
console.log(this.equipListactive, index);
|
|
|
this.equipListactive = index;
|
|
|
- console.log(this.equipListactive, index);
|
|
|
- // this.initmap(item);
|
|
|
- // this.zoom = 10;
|
|
|
- // console.log(item);
|
|
|
this.init(item);
|
|
|
},
|
|
|
//基地双击
|
|
|
@@ -761,170 +639,40 @@ export default {
|
|
|
},
|
|
|
// 构建多边形结束
|
|
|
drawingEnd(evt) {
|
|
|
+ var area = evt.feature.getGeometry().getArea(); //获取绘制的地区面积
|
|
|
+ var unit = "";
|
|
|
+ if (area > 1000000) {
|
|
|
+ area = area / 1000000;
|
|
|
+ unit = "km²";
|
|
|
+ } else {
|
|
|
+ unit = "m²";
|
|
|
+ }
|
|
|
+ console.log(area + unit);
|
|
|
+ console.log((area + area / 2) / 1000 + "亩"); //平方米换算成亩
|
|
|
+ var y = (area + area / 2) / 1000;
|
|
|
+ console.log((y * 2000) / 3); //亩换算成平方米
|
|
|
+
|
|
|
let that = this;
|
|
|
const geo = evt.feature.getGeometry();
|
|
|
const t = geo.getType();
|
|
|
if (t === "Polygon") {
|
|
|
// 获取坐标点
|
|
|
const points = geo.getCoordinates();
|
|
|
+ console.log(geo);
|
|
|
console.warn(points, "绘制结束,点坐标");
|
|
|
- console.log(this.source);
|
|
|
+ // console.log(this.source);
|
|
|
this.source.clear();
|
|
|
// this.aerialmap.addInteraction(this.draw);
|
|
|
this.aerialmap.removeInteraction(this.draw); // 移除绘制
|
|
|
}
|
|
|
},
|
|
|
clealdraw() {
|
|
|
- console.log(1);
|
|
|
- // this.drawVector.getSource().removeFeature();
|
|
|
- console.log(this.drawarr);
|
|
|
+ // console.log(1);
|
|
|
+ // // this.drawVector.getSource().removeFeature();
|
|
|
+ // console.log(this.drawarr);
|
|
|
this.aerialmap.removeLayer(this.drawarr[this.drawarr.length - 1]);
|
|
|
this.drawarr.pop();
|
|
|
},
|
|
|
- // addInteraction() {
|
|
|
- // this.drawVector = new ol.layer.Vector({
|
|
|
- // //数据源
|
|
|
- // source: new ol.source.Vector(),
|
|
|
- // //样式
|
|
|
- // style: new ol.style.Style({
|
|
|
- // //样式填充
|
|
|
- // fill: new ol.style.Fill({
|
|
|
- // //填充颜色
|
|
|
- // color: "rgba(37,241,239,0.2)",
|
|
|
- // }),
|
|
|
- // //笔触
|
|
|
- // stroke: new ol.style.Stroke({
|
|
|
- // //笔触颜色
|
|
|
- // color: "#264df6",
|
|
|
- // //笔触宽度
|
|
|
- // width: 2,
|
|
|
- // }),
|
|
|
- // //图形样式,主要适用于点样式
|
|
|
- // image: new ol.style.Circle({
|
|
|
- // //半径大小
|
|
|
- // radius: 7,
|
|
|
- // //填充
|
|
|
- // fill: new ol.style.Fill({
|
|
|
- // //填充颜色
|
|
|
- // color: "#e81818",
|
|
|
- // }),
|
|
|
- // }),
|
|
|
- // }),
|
|
|
- // });
|
|
|
- // this.aerialmap.addLayer(this.drawVector);
|
|
|
- // //设置矢量图层的数据源为空
|
|
|
- // this.drawVector.setSource(null);
|
|
|
- // var typeSelect = "Polygon"; //Point 点 LineString 线 Polygon 多边形 Circle 圆 Square 正方形 Rectangle 长方形
|
|
|
-
|
|
|
- // //添加绘图交互的函数
|
|
|
- // // var source = new ol.source.Vector({ wrapX: false });
|
|
|
- // //获取当前选择的绘图类型
|
|
|
- // var value = typeSelect;
|
|
|
- // //如果当前选择的绘图类型不为"None"的话,则进行相应绘图操作
|
|
|
- // //如果当前选择的绘图类型为"None"的话,则清空矢量数据源
|
|
|
- // if (value !== "None") {
|
|
|
- // //如果当前的矢量数据源为空的话,则重新创建和设置数据源
|
|
|
- // //因为当你选择的绘图类型为"None"时,会清空数据源
|
|
|
- // if (this.drawVector.getSource() == null) {
|
|
|
- // this.drawVector.setSource(new ol.source.Vector({ wrapX: false }));
|
|
|
- // }
|
|
|
- // //geometryFunction变量,用来存储绘制图形时的回调函数
|
|
|
- // //maxPoints变量,用来存储最大的点数量
|
|
|
- // var geometryFunction, maxPoints;
|
|
|
- // //如果当前选择的绘图类型是"Square"的话,则将value设置为Circle
|
|
|
- // //然后调用createRegularPolygon()方法
|
|
|
- // if (value === "Square") {
|
|
|
- // value = "Circle";
|
|
|
- // //根据圆来创建一个四边形
|
|
|
- // geometryFunction = ol.interaction.Draw.createRegularPolygon(4);
|
|
|
- // } else if (value === "Rectangle") {
|
|
|
- // //长方形
|
|
|
- // //如果当前选择的绘图类型是"Square"的话,则将value设置为LineString
|
|
|
- // value = "LineString";
|
|
|
-
|
|
|
- // //设置最大点数为2
|
|
|
- // maxPoints = 2;
|
|
|
-
|
|
|
- // geometryFunction = function (coordinates, geometry) {
|
|
|
- // //source.clear();
|
|
|
-
|
|
|
- // //如果geometry对象不存在或者为空,则创建
|
|
|
- // if (!geometry) {
|
|
|
- // geometry = new ol.geom.Polygon(null);
|
|
|
- // }
|
|
|
- // //开始点的坐标
|
|
|
- // var start = coordinates[0];
|
|
|
- // //结束点的坐标
|
|
|
- // var end = coordinates[1];
|
|
|
- // //根据开始坐标和结束坐标设置绘图点坐标
|
|
|
- // geometry.setCoordinates([
|
|
|
- // [start, [start[0], end[1]], end, [end[0], start[1]], start],
|
|
|
- // ]);
|
|
|
-
|
|
|
- // return geometry;
|
|
|
- // };
|
|
|
- // }
|
|
|
-
|
|
|
- // //将交互绘图对象赋给draw对象
|
|
|
- // //初始化交互绘图对象
|
|
|
- // var draw = new ol.interaction.Draw({
|
|
|
- // //图层数据源
|
|
|
- // source: this.drawVector.getSource(),
|
|
|
- // //绘制类型
|
|
|
- // type: value,
|
|
|
- // //回调函数
|
|
|
- // //Function that is called when a geometry's coordinates are updated
|
|
|
- // geometryFunction: geometryFunction,
|
|
|
- // //最大点数
|
|
|
- // maxPoints: maxPoints,
|
|
|
- // });
|
|
|
- // //将draw对象添加到map中,然后就可以进行图形绘制了
|
|
|
- // this.aerialmap.addInteraction(draw);
|
|
|
-
|
|
|
- // draw.setActive(true);
|
|
|
- // }
|
|
|
-
|
|
|
- // //监听开始事件
|
|
|
-
|
|
|
- // draw.on("drawstart", () => {
|
|
|
- // //alert("111");
|
|
|
- // // this.drawVector.getSource().clear();
|
|
|
- // });
|
|
|
-
|
|
|
- // //获取坐标
|
|
|
- // draw.on("drawend", function (evt) {
|
|
|
- // //alert("111");
|
|
|
- // var feature = evt.feature;
|
|
|
- // var geometry = feature.getGeometry();
|
|
|
-
|
|
|
- // //获取多边形的坐标
|
|
|
- // //var coordinate = geometry.getCoordinates();
|
|
|
- // //获取圆的坐标
|
|
|
- // //var coordinate = geometry.getCenter();
|
|
|
-
|
|
|
- // var lnglat = [];
|
|
|
- // //for(var i =0;i<)
|
|
|
- // var points = [];
|
|
|
-
|
|
|
- // //获取坐标
|
|
|
- // if (typeSelect == "Circle") {
|
|
|
- // points = geometry.getCenter();
|
|
|
- // lnglat = ol.proj.transform(points, "EPSG:3857", "EPSG:4326");
|
|
|
- // //radius = circle.getRadius();
|
|
|
- // console.log(geometry.getRadius());
|
|
|
- // console.log(lnglat);
|
|
|
- // } else {
|
|
|
- // points = geometry.getCoordinates();
|
|
|
- // console.log(points);
|
|
|
- // for (var i = 0; i < points.length; i++) {
|
|
|
- // lnglat.push(ol.proj.transform(points[i], "EPSG:3857", "EPSG:4326"));
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // console.log(lnglat);
|
|
|
- // // console.log(geometry.getCoordinates());
|
|
|
- // });
|
|
|
- // },
|
|
|
},
|
|
|
beforeCreate() {}, //生命周期 - 创建之前
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
|
@@ -932,16 +680,19 @@ export default {
|
|
|
beforeMount() {}, //生命周期 - 挂载之前
|
|
|
//生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
mounted() {
|
|
|
- // this.initmap(this.mapData[0]);
|
|
|
this.init(this.mapData[0]);
|
|
|
- // 482740.5626,3377273.7481,1055990.5626,3924273.7481
|
|
|
- console.log(
|
|
|
- gcoord.transform(
|
|
|
- [482740.5626, 3377273.7481],
|
|
|
- gcoord.EPSG3857,
|
|
|
- gcoord.GCJ02
|
|
|
- )
|
|
|
+ // '113.67426470134029', '113.67730349366221', '34.811014906789666', '34.81346642108534'
|
|
|
+ var a = gcoord.transform(
|
|
|
+ [113.67426470134029, 34.811014906789666],
|
|
|
+ gcoord.EPSG4326,
|
|
|
+ gcoord.EPSG3857
|
|
|
+ );
|
|
|
+ var b = gcoord.transform(
|
|
|
+ [113.67730349366221, 34.81346642108534],
|
|
|
+ gcoord.EPSG4326,
|
|
|
+ gcoord.EPSG3857
|
|
|
);
|
|
|
+ console.log(a, b);
|
|
|
},
|
|
|
beforeUpdate() {}, //生命周期 - 更新之前
|
|
|
updated() {}, //生命周期 - 更新之后
|