坐标修改、提示框样式修改
This commit is contained in:
@ -68,6 +68,58 @@ const MouseCoordinate = (sdk, status) => {
|
||||
tmovement = { ...movement.endPosition }
|
||||
})
|
||||
|
||||
const posiToCoordinate = (coordinateSystem, position) => {
|
||||
let type
|
||||
switch (coordinateSystem) {
|
||||
case 'EPSG:32601'://WGS84 通用横轴墨卡托投影
|
||||
//带号 = ⌊(经度 + 180)/6⌋ + 1
|
||||
var dh = Math.round((position.lng + 180) / 6 + 1)
|
||||
|
||||
if (position.lat > 0) {//北纬
|
||||
type = 32600 + dh
|
||||
type = 'EPSG:' + type
|
||||
} else {//南纬
|
||||
type = 32700 + dh
|
||||
type = 'EPSG:' + type
|
||||
}
|
||||
break;
|
||||
case 'EPSG:4534'://2000 坐标 3 度不带代号
|
||||
//N = round(经度/3)
|
||||
//EPSG = N - 25 + 4534
|
||||
|
||||
var dh3y = Math.round(position.lng / 3)
|
||||
type = dh3y - 25 + 4534
|
||||
type = 'EPSG:' + type
|
||||
break;
|
||||
case 'EPSG:4513'://2000 坐标 3 度带代号
|
||||
//N = round(经度/3)
|
||||
//EPSG = N - 25 + 4513
|
||||
var dh3w = Math.round(position.lng / 3)
|
||||
type = dh3w - 25 + 4513
|
||||
type = 'EPSG:' + type
|
||||
break;
|
||||
case 'EPSG:4502'://2000 坐标 6 度不带代号
|
||||
let zoneNumber = Math.floor(position.lng / 6) + 31
|
||||
// 中国区域6度带带号范围为13-23
|
||||
if (zoneNumber < 13) zoneNumber = 13;
|
||||
if (zoneNumber > 23) zoneNumber = 23;
|
||||
type = (zoneNumber - 13) + 4502
|
||||
type = 'EPSG:' + type
|
||||
break;
|
||||
case 'EPSG:4491'://2000 坐标 6 度带代号
|
||||
//N = floor(longitude/6) + 31
|
||||
var dh6 = Math.floor(position.lng / 6) + 31
|
||||
// 中国区域6度带带号范围为13-23
|
||||
if (dh6 < 13) dh6 = 13;
|
||||
if (dh6 > 23) dh6 = 23;
|
||||
type = (dh6 - 13) + 4491
|
||||
type = 'EPSG:' + type
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return type
|
||||
}
|
||||
const getPosition = () => {
|
||||
if (!targetSdk) {
|
||||
return
|
||||
@ -142,7 +194,8 @@ const MouseCoordinate = (sdk, status) => {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let result = tools.convert([{ x: degrees.lng, y: degrees.lat, z: degrees.alt }], 'EPSG:4326', coordinateSystem)
|
||||
// let result = tools.convert([{ x: degrees.lng, y: degrees.lat, z: degrees.alt }], 'EPSG:4326', coordinateSystem)
|
||||
let result = tools.convert([{ x: degrees.lng, y: degrees.lat, z: degrees.alt }], 'EPSG:4326', posiToCoordinate(coordinateSystem, degrees))
|
||||
position = result.points[0]
|
||||
contentElm.innerHTML = `<div style='width: 150px;position: absolute; z-index: 777; color: #ff0000; font-size: 12px; left:${left + 20}px; top:${top + 10}px;'><p style='margin: 0;'>x:${position.x.toFixed(6)}</p><p style='margin: 0;'>y:${position.y.toFixed(6)}</p><p style='margin: 0;'>z:${position.z.toFixed(6)}</p></div>`
|
||||
}
|
||||
|
||||
@ -230,14 +230,17 @@ function CesiumContainer(sdk, options) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', coordinateSystem)
|
||||
console.log(result, 'result12');
|
||||
// let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', coordinateSystem)
|
||||
let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', posiToCoordinate(coordinateSystem, position))
|
||||
if (result.points.length) {
|
||||
infoElm.innerHTML = `
|
||||
<span>x:</span><span>${Number(result.points[0].x.toFixed(6))}</span>
|
||||
<span style="margin-left: 5px;">y:</span><span>${Number(result.points[0].y.toFixed(6))}</span>
|
||||
<span style="margin-left: 5px;">z:</span><span>${Number(result.points[0].z.toFixed(6))}</span>
|
||||
`
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -803,8 +806,8 @@ function setCoordinateSystem(sdk, epsg) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', coordinateSystem)
|
||||
console.log(result, 'result')
|
||||
// let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', coordinateSystem)
|
||||
let result = proj.convert([{ x: position.lng, y: position.lat, z: position.alt }], 'EPSG:4326', posiToCoordinate(coordinateSystem, position))
|
||||
infoElm.innerHTML = `
|
||||
<span>x:</span><span>${Number(result.points[0].x.toFixed(6))}</span>
|
||||
<span style="margin-left: 5px;">y:</span><span>${Number(result.points[0].y.toFixed(6))}</span>
|
||||
@ -812,7 +815,58 @@ function setCoordinateSystem(sdk, epsg) {
|
||||
`
|
||||
}
|
||||
}
|
||||
function posiToCoordinate(coordinateSystem, position) {
|
||||
let type
|
||||
switch (coordinateSystem) {
|
||||
case 'EPSG:32601'://WGS84 通用横轴墨卡托投影
|
||||
//带号 = ⌊(经度 + 180)/6⌋ + 1
|
||||
var dh = Math.floor((position.lng + 180) / 6 + 1)
|
||||
|
||||
if (position.lat > 0) {//北纬
|
||||
type = 32600 + dh
|
||||
type = 'EPSG:' + type
|
||||
} else {//南纬
|
||||
type = 32700 + dh
|
||||
type = 'EPSG:' + type
|
||||
}
|
||||
break;
|
||||
case 'EPSG:4534'://2000 坐标 3 度不带代号
|
||||
//N = round(经度/3)
|
||||
//EPSG = N - 25 + 4534
|
||||
|
||||
var dh3y = Math.round(position.lng / 3)
|
||||
type = dh3y - 25 + 4534
|
||||
type = 'EPSG:' + type
|
||||
break;
|
||||
case 'EPSG:4513'://2000 坐标 3 度带代号
|
||||
//N = round(经度/3)
|
||||
//EPSG = N - 25 + 4513
|
||||
var dh3w = Math.round(position.lng / 3)
|
||||
type = dh3w - 25 + 4513
|
||||
type = 'EPSG:' + type
|
||||
break;
|
||||
case 'EPSG:4502'://2000 坐标 6 度不带代号
|
||||
let zoneNumber = Math.floor(position.lng / 6) + 31
|
||||
// 中国区域6度带带号范围为13-23
|
||||
if (zoneNumber < 13) zoneNumber = 13;
|
||||
if (zoneNumber > 23) zoneNumber = 23;
|
||||
type = (zoneNumber - 13) + 4502
|
||||
type = 'EPSG:' + type
|
||||
break;
|
||||
case 'EPSG:4491'://2000 坐标 6 度带代号
|
||||
//N = floor(longitude/6) + 31
|
||||
var dh6 = Math.floor(position.lng / 6) + 31
|
||||
// 中国区域6度带带号范围为13-23
|
||||
if (dh6 < 13) dh6 = 13;
|
||||
if (dh6 > 23) dh6 = 23;
|
||||
type = (dh6 - 13) + 4491
|
||||
type = 'EPSG:' + type
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return type
|
||||
}
|
||||
function getDMS() {
|
||||
return positionType
|
||||
}
|
||||
|
||||
@ -3862,12 +3862,24 @@
|
||||
}
|
||||
|
||||
#YJ-custom-message.success {
|
||||
background-color: #f0f9eb;
|
||||
color: rgb(82, 196, 26);
|
||||
/* background-color: #f0f9eb; */
|
||||
/* color: rgb(82, 196, 26); */
|
||||
background:
|
||||
linear-gradient(180deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
||||
linear-gradient(0deg, rgba(27, 248, 195, 0.5) 0%, rgba(27, 248, 195, 0) 100%);
|
||||
font-size: 14px !important;
|
||||
font-weight: 500 !important;
|
||||
color: rgba(27, 248, 195, 1);
|
||||
}
|
||||
#YJ-custom-message.warning {
|
||||
background-color: #fdf6ec;
|
||||
color: #e6a23c;
|
||||
/* background-color: #fdf6ec;
|
||||
color: #e6a23c; */
|
||||
background:
|
||||
linear-gradient(180deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
||||
linear-gradient(0deg, rgba(255, 161, 69, 0.5) 0%, rgba(255, 161, 69, 0) 100%);
|
||||
font-size: 14px !important;
|
||||
font-weight: 500 !important;
|
||||
color: rgba(255, 161, 69, 1)
|
||||
}
|
||||
|
||||
/* 滑入动画 */
|
||||
|
||||
Reference in New Issue
Block a user