This commit is contained in:
汪汇 2024-01-19 16:18:40 +08:00
parent 8bc0088be5
commit e6af4fee08
2 changed files with 11 additions and 22 deletions

View File

@ -2,7 +2,6 @@ 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;
@ -46,7 +45,6 @@ function transformlng(lng, lat) {
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;
@ -54,23 +52,15 @@ function latLng2WebMercator(lng, lat) {
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];
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

@ -380,7 +380,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);
map.centerAndZoom(new T.LngLat(lest[0], lest[1]), 17);
showdata.value = e;
map.clearOverLays();
dropdown.rmyy.forEach((item, index) => {
@ -392,6 +392,7 @@ const addClickHandls = (e) => {
});
let ss = item.xiang_xi_di_zhi_jing_wei_du.split(",");
ss = gcj02towgs84(ss[0], ss[1]);
console.log(ss);
var LngLats = new T.Marker(new T.LngLat(ss[0], ss[1]), {
icon: icons,
@ -440,7 +441,6 @@ 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;
@ -455,7 +455,6 @@ const getlist = () => {
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();