2025-04-29 16:36:51 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div :style="{width:'100vw',height}">
|
2025-04-30 14:35:16 +08:00
|
|
|
|
<map id="mapRef" ref="mapRef" :style="{width:'100vw',height}" show-location :longitude="mapcenter.longitude"
|
|
|
|
|
|
:latitude="mapcenter.latitude" :markers="markers" :polygons="polygons" :circles="circles"
|
|
|
|
|
|
:polyline="polyline" :scale="scale" @tap="mapTap" />
|
2025-04-29 16:36:51 +08:00
|
|
|
|
<div class="divNav">
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="divLowerLeft">
|
|
|
|
|
|
<div class="divBtn">
|
|
|
|
|
|
<div class="divBtnTitle" @click="getLocation">
|
|
|
|
|
|
<uni-icons custom-prefix="iconfont" type="icon-ebikedingwei2" :color="iconcolor" :size="iconsize" />
|
|
|
|
|
|
<div>定位</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="divBtnTitle" @click="refreshArea">
|
|
|
|
|
|
<uni-icons custom-prefix="iconfont" type="icon-ebikeshuaxin" :color="iconcolor" :size="iconsize" />
|
|
|
|
|
|
<div>刷新</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="divBtnTitle" style="padding-bottom: 10px;"
|
|
|
|
|
|
@click="()=>{showRegion=!showRegion;showMapSite(!showRegion)}">
|
|
|
|
|
|
<uni-icons custom-prefix="iconfont" type="icon-ebikeP" :color="!showRegion?iconcolor:showColor"
|
|
|
|
|
|
:size="iconsize" />
|
|
|
|
|
|
<div :style="{color:!showRegion?iconcolor:showColor}">站点</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="showDraw" class="divBottom">
|
|
|
|
|
|
<div style="display: flex;">
|
|
|
|
|
|
<label>选择形状:</label>
|
|
|
|
|
|
<div style="margin-top: -5px;">
|
|
|
|
|
|
<uni-data-checkbox v-model="selDraw" :localdata="drawType"
|
|
|
|
|
|
@change="changDrawType"></uni-data-checkbox>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="selDraw=='1'" style="line-height: 35px;">
|
|
|
|
|
|
<label class="lbWorn">请点击地图绘制您想绘制的区域</label>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<label class="b-btn-blue" @click="delPoint">删除点</label>
|
|
|
|
|
|
<label class="b-btn-blue" style="margin-left: 15px;" @click="clearPoint">清空点</label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="selDraw=='2'">
|
|
|
|
|
|
<label class="lbWorn">
|
|
|
|
|
|
请点
|
|
|
|
|
|
<uni-icons type="plus" color="#1082FF" size="30" @click="onZoom('out')" />
|
|
|
|
|
|
击放
|
|
|
|
|
|
大圆,点击<uni-icons type="minus" color="#1082FF" size="30" @click="onZoom('in')" />
|
|
|
|
|
|
缩小圆,半径为:
|
|
|
|
|
|
|
|
|
|
|
|
<label style="color: #000;">{{radius}}</label>
|
|
|
|
|
|
米
|
|
|
|
|
|
</label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="text-align: center;display: flex;justify-content: space-evenly;margin: 10px 0px;">
|
|
|
|
|
|
<div class="b-btn-white" style="width:100%;margin-right: 10px" @click="cancelDraw">取消绘制</div>
|
|
|
|
|
|
<div class="b-btn-blue" style="width:100%;" @click="completeDraw">完成绘制</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import {
|
|
|
|
|
|
ref,
|
|
|
|
|
|
onMounted,
|
|
|
|
|
|
getCurrentInstance
|
|
|
|
|
|
} from 'vue';
|
|
|
|
|
|
import * as map from "@/utils/map.js";
|
|
|
|
|
|
import {
|
|
|
|
|
|
useSelarea
|
|
|
|
|
|
} from "@/stores/selarea.js";
|
|
|
|
|
|
import {
|
|
|
|
|
|
onLoad
|
|
|
|
|
|
} from "@dcloudio/uni-app";
|
|
|
|
|
|
import {
|
|
|
|
|
|
showModelMessage,
|
|
|
|
|
|
getScreenHeightNoTabBar
|
|
|
|
|
|
} from "@/utils/tools.js";
|
|
|
|
|
|
import {
|
|
|
|
|
|
cloneDeep,
|
|
|
|
|
|
findIndex
|
|
|
|
|
|
} from "lodash"
|
|
|
|
|
|
|
|
|
|
|
|
const title = ref("新建站点");
|
|
|
|
|
|
let isload = false;
|
|
|
|
|
|
let oMap = null;
|
2025-04-30 14:35:16 +08:00
|
|
|
|
const mapcenter = ref({
|
|
|
|
|
|
longitude: "",
|
|
|
|
|
|
latitude: ""
|
|
|
|
|
|
})
|
2025-04-29 16:36:51 +08:00
|
|
|
|
const scale = ref(18);
|
|
|
|
|
|
const polygons = ref([]);
|
|
|
|
|
|
const circles = ref([]);
|
|
|
|
|
|
const markers = ref([]);
|
|
|
|
|
|
const polyline = ref([]);
|
|
|
|
|
|
|
|
|
|
|
|
const radius = ref(20);
|
|
|
|
|
|
let drawPoint = [];
|
|
|
|
|
|
let areaData = {};
|
|
|
|
|
|
let regionData = {};
|
|
|
|
|
|
let showRegion = ref(false);
|
|
|
|
|
|
const iconsize = 16;
|
|
|
|
|
|
const iconcolor = "#6f7777";
|
|
|
|
|
|
const showColor = "#1088FD";
|
|
|
|
|
|
|
|
|
|
|
|
//行政区划
|
|
|
|
|
|
const selAreaStore = useSelarea();
|
|
|
|
|
|
const zoneId = selAreaStore.value;
|
|
|
|
|
|
const showDraw = ref(false);
|
|
|
|
|
|
const drawType = [{
|
|
|
|
|
|
text: "多边形",
|
|
|
|
|
|
value: "1"
|
|
|
|
|
|
}, {
|
|
|
|
|
|
text: "圆形",
|
|
|
|
|
|
value: "2"
|
|
|
|
|
|
}];
|
|
|
|
|
|
const selDraw = ref("1");
|
|
|
|
|
|
const drawId = 10000000;
|
|
|
|
|
|
const drawColor = "#e58b04";
|
2025-04-29 18:34:06 +08:00
|
|
|
|
const drawFillColor = "#e58b041a";
|
2025-04-29 16:36:51 +08:00
|
|
|
|
const height = ref("100vh");
|
|
|
|
|
|
const opentype = ref("add"); //打开类型
|
2025-04-29 18:34:06 +08:00
|
|
|
|
let editId = ""; //编辑ID
|
2025-04-29 16:36:51 +08:00
|
|
|
|
|
|
|
|
|
|
//缩放
|
|
|
|
|
|
function onZoom(type) {
|
|
|
|
|
|
const i = 10;
|
|
|
|
|
|
let r = radius.value;
|
|
|
|
|
|
if (!drawPoint || drawPoint.length == 0) {
|
|
|
|
|
|
showModelMessage("请先绘制图形!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case "out":
|
|
|
|
|
|
r += 10;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
if (r == 20) {
|
|
|
|
|
|
showModelMessage("已缩放至最小!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
r = r - 10;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
radius.value = r;
|
|
|
|
|
|
const {
|
|
|
|
|
|
latitude,
|
|
|
|
|
|
longitude
|
|
|
|
|
|
} = drawPoint[0];
|
2025-04-29 18:34:06 +08:00
|
|
|
|
circles.value[circles.value.length - 1] = map.addCirle(drawColor, drawFillColor, longitude, latitude, radius
|
|
|
|
|
|
.value);
|
2025-04-29 16:36:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//切换绘制类型
|
|
|
|
|
|
function changDrawType(e) {
|
|
|
|
|
|
const {
|
|
|
|
|
|
value
|
|
|
|
|
|
} = e.detail;
|
|
|
|
|
|
selDraw.value = value;
|
|
|
|
|
|
if (!drawPoint || drawPoint.length == 0) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
markers.value.splice(markers.value.length - 1, 1);
|
|
|
|
|
|
switch (drawPoint.length) {
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
polyline.value = [];
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
polygons.value.splice(polygons.value.length - 1, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
drawPoint = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function mapTap(e) {
|
|
|
|
|
|
if (!showDraw.value) return;
|
|
|
|
|
|
const {
|
|
|
|
|
|
detail: {
|
|
|
|
|
|
latitude,
|
|
|
|
|
|
longitude
|
|
|
|
|
|
}
|
|
|
|
|
|
} = e;
|
|
|
|
|
|
switch (selDraw.value) {
|
|
|
|
|
|
case "1":
|
|
|
|
|
|
drawPolygons(latitude, longitude);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "2":
|
|
|
|
|
|
drawCircle(latitude, longitude);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//绘制多边形
|
|
|
|
|
|
function drawPolygons(latitude, longitude) {
|
|
|
|
|
|
const len = drawPoint.length;
|
|
|
|
|
|
switch (len) {
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
const marker = map.addMarker(drawId, longitude, latitude, "point.png");
|
|
|
|
|
|
markers.value.push(marker);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
polyline.value.push(map.addLine(drawColor, drawPoint));
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
polyline.value.splice(polyline.value.length - 1, 1);
|
|
|
|
|
|
polygons.value.push(map.addPolygon(drawColor, drawFillColor, drawPoint));
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
polygons.value[polygons.value.length - 1] = map.addPolygon(drawColor, drawFillColor, drawPoint);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
drawPoint.push({
|
|
|
|
|
|
latitude,
|
|
|
|
|
|
longitude
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//绘制圆形
|
|
|
|
|
|
function drawCircle(latitude, longitude) {
|
|
|
|
|
|
const circle = map.addCirle(drawColor, drawFillColor, longitude, latitude, radius.value);
|
2025-04-29 18:34:06 +08:00
|
|
|
|
const marker = map.addMarker(drawId, longitude, latitude, "point.png");
|
2025-04-29 16:36:51 +08:00
|
|
|
|
if (drawPoint.length > 0) {
|
|
|
|
|
|
circles.value[circles.value.length - 1] = circle;
|
2025-04-29 18:34:06 +08:00
|
|
|
|
markers.value[markers.value.length - 1] = markers;
|
2025-04-29 16:36:51 +08:00
|
|
|
|
} else {
|
2025-04-29 18:34:06 +08:00
|
|
|
|
|
2025-04-29 16:36:51 +08:00
|
|
|
|
markers.value.push(marker);
|
|
|
|
|
|
circles.value.push(circle);
|
|
|
|
|
|
}
|
|
|
|
|
|
drawPoint[0] = {
|
|
|
|
|
|
latitude,
|
|
|
|
|
|
longitude
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//删除点
|
|
|
|
|
|
function delPoint() {
|
|
|
|
|
|
if (!drawPoint || drawPoint.length == 0) {
|
|
|
|
|
|
showModelMessage("请先绘制点!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
drawPoint.splice(drawPoint.length - 1, 1);
|
|
|
|
|
|
if (selDraw.value == "1") {
|
|
|
|
|
|
delPolygon();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
markers.value.splice(markers.value.length - 1, 1);
|
|
|
|
|
|
circles.value.splice(circles.value.length - 1, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function delPolygon() {
|
|
|
|
|
|
switch (drawPoint.length) {
|
|
|
|
|
|
case 0:
|
|
|
|
|
|
markers.value.splice(markers.value.length - 1, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
polyline.value.splice(polyline.value.length - 1, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
polygons.value.splice(polygons.value.length - 1, 1);
|
|
|
|
|
|
polyline.value.push(map.addLine(drawColor, drawPoint));
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
const index = polygons.value.length - 1;
|
|
|
|
|
|
polygons.value[index] = map.addPolygon(drawColor, drawFillColor, drawPoint);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//清除点
|
|
|
|
|
|
function clearPoint() {
|
|
|
|
|
|
drawPoint = [];
|
|
|
|
|
|
markers.value.splice(markers.value.length - 1, 1);
|
|
|
|
|
|
if (selDraw.value == "1") {
|
|
|
|
|
|
polygons.value.splice(polygons.value.length - 1, 1);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
circles.value.splice(circles.value.length - 1, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//完成绘制
|
|
|
|
|
|
function completeDraw() {
|
|
|
|
|
|
if (drawPoint.length == 0) {
|
|
|
|
|
|
showModelMessage("请先绘制区域!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const arrPoint = cloneDeep(drawPoint)
|
|
|
|
|
|
if (selDraw.value == "1" && arrPoint.length <= 3) {
|
|
|
|
|
|
showModelMessage("至少四个点进行区域绘制!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (arrPoint.length > 3) {
|
|
|
|
|
|
arrPoint.push(arrPoint[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
const points = JSON.stringify(arrPoint);
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: `/pages/devops/bikesite/bikesite-info?points=${points}&radius=${radius.value}&&type=${opentype.value}`
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//取消绘制
|
|
|
|
|
|
function cancelDraw() {
|
|
|
|
|
|
uni.navigateBack();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadOperation(callback) {
|
2025-04-29 18:34:06 +08:00
|
|
|
|
console.log("666666666666666666666", "行政区划", zoneId);
|
2025-04-30 14:35:16 +08:00
|
|
|
|
|
2025-04-29 16:36:51 +08:00
|
|
|
|
map.getOperation(zoneId, (res) => {
|
|
|
|
|
|
if (!res) {
|
2025-04-30 14:35:16 +08:00
|
|
|
|
if (callback) callback();
|
2025-04-29 16:36:51 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const {
|
|
|
|
|
|
arrRegionID,
|
|
|
|
|
|
arrCircles,
|
|
|
|
|
|
arrPolygons,
|
|
|
|
|
|
arrData
|
|
|
|
|
|
} = res;
|
|
|
|
|
|
if (arrRegionID.length == 0) {
|
2025-04-30 14:35:16 +08:00
|
|
|
|
if (callback) callback();
|
2025-04-29 16:36:51 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
areaData = {
|
|
|
|
|
|
arrCircles,
|
|
|
|
|
|
arrPolygons,
|
|
|
|
|
|
arrData
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
map.getRegionData(arrRegionID, (res) => {
|
2025-04-30 14:35:16 +08:00
|
|
|
|
console.log("11111111111getRegionData", res);
|
2025-04-29 16:36:51 +08:00
|
|
|
|
const {
|
|
|
|
|
|
arrData,
|
|
|
|
|
|
arrCircles: arrCircles_region,
|
|
|
|
|
|
arrPolygons: arrPolygons_region,
|
|
|
|
|
|
arrCirclesData,
|
|
|
|
|
|
arrPolygonsData
|
|
|
|
|
|
} = res;
|
|
|
|
|
|
regionData = {
|
|
|
|
|
|
arrCircles,
|
|
|
|
|
|
arrPolygons,
|
|
|
|
|
|
arrCirclesData,
|
|
|
|
|
|
arrPolygonsData
|
|
|
|
|
|
};
|
|
|
|
|
|
const arrMarker = [];
|
|
|
|
|
|
arrCircles_region.map((item, index) => {
|
|
|
|
|
|
const {
|
|
|
|
|
|
latitude: lat,
|
|
|
|
|
|
longitude: lng
|
|
|
|
|
|
} = item;
|
|
|
|
|
|
const len = arrMarker.length;
|
|
|
|
|
|
arrMarker.push(map.addMarker(len + index, lng, lat, "bikesite.png"));
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-04-29 18:34:06 +08:00
|
|
|
|
arrPolygons_region.map((item, index) => {
|
2025-04-29 16:36:51 +08:00
|
|
|
|
const {
|
|
|
|
|
|
points
|
|
|
|
|
|
} = item;
|
|
|
|
|
|
const {
|
|
|
|
|
|
lng,
|
|
|
|
|
|
lat
|
|
|
|
|
|
} = map.getPolygonCenter(points)
|
|
|
|
|
|
const len = arrMarker.length;
|
|
|
|
|
|
arrMarker.push(map.addMarker(len + index, lng, lat, "bikesite.png"));
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
markers.value = arrMarker;
|
|
|
|
|
|
showMapSite(showRegion.value);
|
2025-04-30 14:35:16 +08:00
|
|
|
|
if (callback) callback();
|
2025-04-29 16:36:51 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//定位
|
|
|
|
|
|
function getLocation() {
|
|
|
|
|
|
map.getLoalcation(oMap, (res) => {
|
|
|
|
|
|
const {
|
|
|
|
|
|
latitude,
|
|
|
|
|
|
longitude
|
|
|
|
|
|
} = res;
|
2025-04-30 14:35:16 +08:00
|
|
|
|
mapcenter.value={
|
|
|
|
|
|
latitude,
|
|
|
|
|
|
longitude
|
|
|
|
|
|
};
|
2025-04-29 16:36:51 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function refreshArea() {
|
|
|
|
|
|
loadOperation();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showMapSite(showSite) {
|
|
|
|
|
|
const {
|
|
|
|
|
|
arrCircles,
|
|
|
|
|
|
arrPolygons
|
|
|
|
|
|
} = areaData;
|
|
|
|
|
|
const {
|
|
|
|
|
|
arrCircles: arrCircles_region,
|
|
|
|
|
|
arrPolygons: arrPolygons_region,
|
|
|
|
|
|
arrCirclesData,
|
|
|
|
|
|
arrPolygonsData
|
|
|
|
|
|
} = regionData;
|
2025-04-30 14:35:16 +08:00
|
|
|
|
const arrEditC = [];
|
|
|
|
|
|
const arrEditP = [];
|
2025-04-29 16:36:51 +08:00
|
|
|
|
if (showSite) {
|
2025-04-29 18:34:06 +08:00
|
|
|
|
if (editId) { //编辑
|
2025-04-29 16:36:51 +08:00
|
|
|
|
const obj = {
|
|
|
|
|
|
regionid: editId
|
|
|
|
|
|
};
|
2025-04-29 18:34:06 +08:00
|
|
|
|
console.log("9999999999999999999999arrCirclesData, arrPolygonsData", arrCirclesData, arrPolygonsData);
|
2025-04-29 16:36:51 +08:00
|
|
|
|
let index = findIndex(arrCirclesData, obj);
|
2025-04-30 14:35:16 +08:00
|
|
|
|
|
2025-04-29 16:36:51 +08:00
|
|
|
|
if (index > -1) {
|
2025-04-30 14:35:16 +08:00
|
|
|
|
const {
|
|
|
|
|
|
latitude,
|
|
|
|
|
|
longitude
|
|
|
|
|
|
} = arrCircles_region[index];
|
2025-04-29 16:36:51 +08:00
|
|
|
|
arrCirclesData.splice(index, 1);
|
|
|
|
|
|
arrCircles_region.splice(index, 1);
|
2025-04-30 14:35:16 +08:00
|
|
|
|
arrEditC.push(map.addCirle(drawColor, drawFillColor, longitude, latitude, radius.value));
|
2025-04-29 16:36:51 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
index = findIndex(arrPolygonsData, obj);
|
2025-04-30 14:35:16 +08:00
|
|
|
|
if (index > -1) {
|
|
|
|
|
|
const {
|
|
|
|
|
|
points: arrPoint
|
|
|
|
|
|
} = arrPolygons_region[index];
|
2025-04-29 18:34:06 +08:00
|
|
|
|
arrPolygonsData.splice(index, 1);
|
|
|
|
|
|
arrPolygons_region.splice(index, 1);
|
2025-04-30 14:35:16 +08:00
|
|
|
|
arrEditP.push(map.addPolygon(drawColor, drawFillColor, arrPoint))
|
2025-04-29 18:34:06 +08:00
|
|
|
|
}
|
2025-04-29 16:36:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-30 14:35:16 +08:00
|
|
|
|
polygons.value = [...arrPolygons, ...arrPolygons_region, ...arrEditP];
|
|
|
|
|
|
circles.value = [...arrCircles, ...arrCircles_region, ...arrEditC];
|
2025-04-29 16:36:51 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
polygons.value = arrPolygons;
|
|
|
|
|
|
circles.value = arrCircles;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-30 14:35:16 +08:00
|
|
|
|
|
2025-04-29 18:34:06 +08:00
|
|
|
|
|
2025-04-29 16:36:51 +08:00
|
|
|
|
|
|
|
|
|
|
function defualtZoom() {
|
2025-04-30 14:35:16 +08:00
|
|
|
|
console.log("888888888888888888defualtZoom", polygons.value)
|
|
|
|
|
|
if (polygons.value.length == 0) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-04-29 16:36:51 +08:00
|
|
|
|
const arrPoint = polygons.value[0].points;
|
|
|
|
|
|
oMap.includePoints({
|
|
|
|
|
|
points: arrPoint,
|
|
|
|
|
|
padding: [50, 50, 50, 50]
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加载数据
|
|
|
|
|
|
function loadData() {
|
|
|
|
|
|
loadOperation(() => {
|
|
|
|
|
|
showMapSite(showRegion.value);
|
|
|
|
|
|
if (isload) {
|
|
|
|
|
|
defualtZoom();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
oMap = map.getMap("mapRef", getCurrentInstance());
|
|
|
|
|
|
//oMap.moveToLocation();
|
|
|
|
|
|
isload = true;
|
2025-04-30 14:35:16 +08:00
|
|
|
|
getLocation();
|
2025-04-29 16:36:51 +08:00
|
|
|
|
defualtZoom();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
onLoad(options => {
|
2025-04-30 14:35:16 +08:00
|
|
|
|
console.log("33333333333333333", "options,isload", options,isload)
|
2025-04-29 16:36:51 +08:00
|
|
|
|
let title = "站点地图";
|
|
|
|
|
|
const {
|
|
|
|
|
|
type,
|
|
|
|
|
|
points,
|
|
|
|
|
|
id,
|
|
|
|
|
|
radius: r
|
|
|
|
|
|
} = options;
|
|
|
|
|
|
if (id) {
|
|
|
|
|
|
editId = id;
|
|
|
|
|
|
drawPoint = JSON.parse(points);
|
|
|
|
|
|
radius.value = r;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
opentype.value = type;
|
|
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case "add":
|
|
|
|
|
|
title = "新建站点";
|
2025-04-29 18:34:06 +08:00
|
|
|
|
showRegion.value = true;
|
|
|
|
|
|
showDraw.value = true;
|
2025-04-29 16:36:51 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case "edit":
|
|
|
|
|
|
title = "编辑站点";
|
2025-04-29 18:34:06 +08:00
|
|
|
|
showRegion.value = true;
|
|
|
|
|
|
showDraw.value = true;
|
2025-04-29 16:36:51 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
getScreenHeightNoTabBar(res => {
|
|
|
|
|
|
height.value = res + "px";
|
|
|
|
|
|
})
|
|
|
|
|
|
uni.setNavigationBarTitle({
|
|
|
|
|
|
title
|
|
|
|
|
|
});
|
2025-04-30 14:35:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-04-29 16:36:51 +08:00
|
|
|
|
loadData();
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
@import url("map-bikesite.css");
|
|
|
|
|
|
</style>
|