This commit is contained in:
汪汇 2024-01-19 14:58:08 +08:00
parent 2c6c42a8aa
commit 8bc0088be5
4 changed files with 106 additions and 9 deletions

View File

@ -9,6 +9,7 @@
},
"dependencies": {
"axios": "^1.6.3",
"gcoord": "^1.0.5",
"pinia": "^2.1.7",
"vant": "^4.8.0",
"vue": "^3.3.4",

76
src/router/dtzh.js Normal file
View File

@ -0,0 +1,76 @@
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

@ -157,7 +157,9 @@
<script setup>
import http from "@/utils/request";
import gcj02towgs84 from "@/router/dtzh";
import { onMounted, ref, reactive, nextTick } from "vue";
import gcoord from "gcoord";
import img1 from "@/assets/home/yysy.png";
import img2 from "@/assets/home/yysyxz.png";
import img3 from "@/assets/home/xyyj.png";
@ -200,7 +202,7 @@ const dropdown = reactive({
const list = reactive({
page: 1,
size: 20,
size: 10,
show: true,
index: 0,
yxfw: [
@ -239,20 +241,20 @@ const list = reactive({
imgs: img10,
columnName: "Retirement",
},
// {
// id: 5,
// name: "",
// img: img11,
// imgs: img12,
// columnName: "HelpDisabled",
// },
{
id: 6,
id: 5,
name: "弱有众扶",
img: img13,
imgs: img14,
columnName: "HelpDisabled",
},
// {
// id: 6,
// name: "",
// img: img11,
// imgs: img12,
// columnName: "HelpDisabled",
// },
],
});
@ -327,6 +329,7 @@ const yxf = () => {
iconAnchor: new T.Point(28, 28),
});
let ss = item.xiang_xi_di_zhi_jing_wei_du.split(",");
ss = gcj02towgs84(ss[0], ss[1]);
var LngLats = new T.Marker(new T.LngLat(ss[0], ss[1]), {
icon: icons,
});
@ -347,6 +350,8 @@ function addClickHandler(content, LngLats) {
iconAnchor: new T.Point(28, 28),
});
let ss = item.xiang_xi_di_zhi_jing_wei_du.split(",");
ss = gcj02towgs84(ss[0], ss[1]);
var LngLats = new T.Marker(new T.LngLat(ss[0], ss[1]), {
icon: icons,
});
@ -359,6 +364,8 @@ function addClickHandler(content, LngLats) {
iconAnchor: new T.Point(28, 28),
});
let ss = item.xiang_xi_di_zhi_jing_wei_du.split(",");
ss = gcj02towgs84(ss[0], ss[1]);
var LngLats = new T.Marker(new T.LngLat(ss[0], ss[1]), {
icon: icons,
});
@ -372,6 +379,7 @@ function addClickHandler(content, LngLats) {
}
const addClickHandls = (e) => {
let lest = e.xiang_xi_di_zhi_jing_wei_du.split(",");
lest = gcj02towgs84(lest[0], lest[1]);
map.centerAndZoom(new T.LngLat(lest[0], lest[1]), 18);
showdata.value = e;
map.clearOverLays();
@ -383,6 +391,8 @@ const addClickHandls = (e) => {
iconAnchor: new T.Point(28, 28),
});
let ss = item.xiang_xi_di_zhi_jing_wei_du.split(",");
ss = gcj02towgs84(ss[0], ss[1]);
var LngLats = new T.Marker(new T.LngLat(ss[0], ss[1]), {
icon: icons,
});
@ -395,6 +405,8 @@ const addClickHandls = (e) => {
iconAnchor: new T.Point(28, 28),
});
let ss = item.xiang_xi_di_zhi_jing_wei_du.split(",");
ss = gcj02towgs84(ss[0], ss[1]);
var LngLats = new T.Marker(new T.LngLat(ss[0], ss[1]), {
icon: icons,
});
@ -428,6 +440,7 @@ const getlist = () => {
data_sorts: [],
};
let patle = "";
console.log(list.index);
patle = list.yxfw[list.index].columnName;
paly.column_id = list.yxfw[list.index].ids;
shows.value = true;
@ -441,6 +454,8 @@ const getlist = () => {
dropdown.rmyy = res.data;
if (dropdown.rmyy.length !== 0) {
let lest = dropdown.rmyy[0].xiang_xi_di_zhi_jing_wei_du.split(",");
lest = gcj02towgs84(lest[0], lest[1]);
console.log(lest);
map.centerAndZoom(new T.LngLat(lest[0], lest[1]), 12);
count.value = res.count;
map.clearOverLays();

View File

@ -357,6 +357,11 @@ fsevents@~2.3.2:
resolved "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
gcoord@^1.0.5:
version "1.0.5"
resolved "https://registry.npmmirror.com/gcoord/-/gcoord-1.0.5.tgz#bd92a1d8d3e8ab9470f5f74fbafffd11ca516413"
integrity sha512-IJjyWd7Q57K36SzoEAZ5LEnhFVXVR3996WJp/3NlleXVBzb/GcORfNhCw8JuZPvSGloHgG0yhPFK4Aqf0t/ohg==
glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"