This commit is contained in:
姚宇浩 2024-08-19 16:53:32 +08:00
parent 6a7d268a79
commit 778231a530
3 changed files with 99 additions and 6 deletions

66
src/utils/gcj02towgs84.js Normal file
View File

@ -0,0 +1,66 @@
var x_PI = 3.14159265358979324 * 3000.0 / 180.0;
var PI = 3.1415926535897932384626;
var a = 6378245.0;
var ee = 0.00669342162296594323;
function gcj02towgs84(lng, lat) {
var lat = +lat;
var lng = +lng;
if (out_of_china(lng, lat)) {
return [lng, lat]
} else {
var dlat = transformlat(lng - 105.0, lat - 35.0);
var dlng = transformlng(lng - 105.0, lat - 35.0);
var radlat = lat / 180.0 * PI;
var magic = Math.sin(radlat);
magic = 1 - ee * magic * magic;
var sqrtmagic = Math.sqrt(magic);
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
var mglat = lat + dlat;
var mglng = lng + dlng;
return [lng * 2 - mglng, lat * 2 - mglat]
}
};
function out_of_china(lng, lat) {
var lat = +lat;
var lng = +lng;
// 纬度3.86~53.55,经度73.66~135.05
return !(lng > 73.66 && lng < 135.05 && lat > 3.86 && lat < 53.55);
};
function transformlat(lng, lat) {
var lat = +lat;
var lng = +lng;
var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
return ret
};
function transformlng(lng, lat) {
var lat = +lat;
var lng = +lng;
var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
return ret
};
function latLng2WebMercator(lng, lat) {
var earthRad = 6378137.0;
var x = lng * Math.PI / 180 * earthRad;
var a = lat * Math.PI / 180;
var y = earthRad / 2 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));
return [x, y]; //[12727039.383734727, 3579066.6894065146]
}
function wgs84utmToGCJ02() {
var retransformX = document.getElementById("retransformX");
var retransformY = document.getElementById("retransformY");
var transformX = document.getElementById("transformX");
var transformY = document.getElementById("transformY");
var g84 = gcj02towgs84(Number(retransformX.value), Number(retransformY.value))
var mer = latLng2WebMercator(g84[0], g84[1])
transformX.value = mer[0];
transformY.value = mer[1];
}
export default gcj02towgs84;

View File

@ -154,6 +154,12 @@
</div> </div>
</div> </div>
</div> </div>
<div class="btns">
<div class="btnopen" @click="openEdit">编辑</div>
<div class="btnsave">保存</div>
<div class="btnclose" @click="closeEdit">取消</div>
</div>
<Dialog <Dialog
:dialogShow="dialogShow" :dialogShow="dialogShow"
:columns="tableType.columns" :columns="tableType.columns"
@ -255,6 +261,7 @@ import xcbg from "@/assets/images/map/xcbg.png";
import AED from "@/assets/images/map/AED.png"; import AED from "@/assets/images/map/AED.png";
import Dialog from "./dialog/dialogMapDp.vue"; import Dialog from "./dialog/dialogMapDp.vue";
import personDetail from "./person/index.vue"; import personDetail from "./person/index.vue";
import gcj02towgs84 from "@/utils/gcj02towgs84.js";
//--------------- //---------------
// //
const loadingss = ref(false); const loadingss = ref(false);
@ -796,6 +803,20 @@ const initMap = () => {
// //
addJd(); addJd();
}; };
//
const openEdit = () => {
console.log(cs_choose_arr.value[0]);
cs_choose_arr.value[0].enableEditing();
// let a=gcj02towgs84(13275212.822414309,3334688.527092757)
// console.log(a);
};
//
const closeEdit = () => {
cs_choose_arr.value[0].disableEditing();
console.log(cs_choose_arr.value[0]);
};
// //
const csh = () => { const csh = () => {
clear(); clear();
@ -2252,7 +2273,7 @@ const addPolygonCounty = () => {
map.clearOverlays(); map.clearOverlays();
let fillColor = "#ffffff"; let fillColor = "#ffffff";
mapTownDataDK.map((item) => { mapTownDataDK.map((item) => {
item.leg = 0; // item.leg = 0;
// //
let points = []; let points = [];
item.point.map((p) => points.push(new BMapGL.Point(...p))); item.point.map((p) => points.push(new BMapGL.Point(...p)));
@ -2503,7 +2524,6 @@ const loadCs = (name) => {
}; };
// //
const addPolygonCountyCs = () => { const addPolygonCountyCs = () => {
// console.log(11111111111111, xkzDk);
xkzDk.map((item, index) => { xkzDk.map((item, index) => {
let num = index % 9; let num = index % 9;
let fillColor = colorList[num].bg; let fillColor = colorList[num].bg;
@ -2985,7 +3005,7 @@ const reset_font2 = () => {
"scale(" + width / 1920 + "," + height / 1080 + ")"; "scale(" + width / 1920 + "," + height / 1080 + ")";
}; };
onMounted(async () => { onMounted(async () => {
// tools.data.set("token", "6b0e380b4a8f46baae4923f83faf670d"); tools.data.set("token", "6b0e380b4a8f46baae4923f83faf670d");
loadingss.value = true; loadingss.value = true;
reset_font(); reset_font();
initMap(); initMap();
@ -3559,7 +3579,14 @@ onMounted(async () => {
} }
} }
} }
.btns {
z-index: 999;
position: absolute;
color: #ffffff;
top: 80px;
left: 600px;
display: flex;
}
.title { .title {
background-image: url(@/assets/images/map/map_title_bg.png); background-image: url(@/assets/images/map/map_title_bg.png);
background-repeat: no-repeat; background-repeat: no-repeat;

View File

@ -15,8 +15,8 @@ export default defineConfig({
// 第一个代理 // 第一个代理
"/api": { "/api": {
// 匹配到啥来进行方向代理 // 匹配到啥来进行方向代理
target: "http://10.0.0.65:8095/", //刘进 // target: "http://10.0.0.65:8095/", //刘进
// target: "http://220.191.238.50:996/", //线上 target: "http://220.191.238.50:996/", //线上
changeOrigin: true, //是否支持跨域 changeOrigin: true, //是否支持跨域
//rewrite: (path) => path.replace(/^\/api/, '') // 如果不需要api 直接把路径上的api 替换成空,这个 //rewrite: (path) => path.replace(/^\/api/, '') // 如果不需要api 直接把路径上的api 替换成空,这个
}, },