坐标类型
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
* 鼠标坐标
|
||||
*/
|
||||
import Tools from "../../Tools";
|
||||
import { getCoordinateSystem } from "../../Global/global";
|
||||
import { getCoordinateSystem, getDMS } from "../../Global/global";
|
||||
import MouseEvent from '../../Event/index'
|
||||
import { getSdk as get2DSdk } from '../../Global/MultiViewportMode'
|
||||
import { getSdk as getSplitScreenSdk } from "../../Global/SplitScreen";
|
||||
@ -21,11 +21,12 @@ const MouseCoordinate = (sdk, status) => {
|
||||
}
|
||||
targetSdk = sdk
|
||||
sdkD = get2DSdk().sdkD
|
||||
if(!sdkD) {
|
||||
if (!sdkD) {
|
||||
sdkD = getSplitScreenSdk().sdkD
|
||||
}
|
||||
|
||||
let tools = new Tools(sdk)
|
||||
let proj = sdk.proj
|
||||
if (status) {
|
||||
if (event) {
|
||||
event.destroy()
|
||||
@ -73,7 +74,7 @@ const MouseCoordinate = (sdk, status) => {
|
||||
}
|
||||
let canvas = sdk.viewer._element.getElementsByTagName('canvas')[0]
|
||||
sdkD = get2DSdk().sdkD
|
||||
if(!sdkD) {
|
||||
if (!sdkD) {
|
||||
sdkD = getSplitScreenSdk().sdkD
|
||||
}
|
||||
if (!event2 && sdkD) {
|
||||
@ -118,13 +119,27 @@ const MouseCoordinate = (sdk, status) => {
|
||||
if (cartesian) {
|
||||
let degrees = tools.cartesian3Towgs84(cartesian, sdk.viewer)
|
||||
let coordinateSystem = getCoordinateSystem()
|
||||
let positionType = getDMS()
|
||||
if (coordinateSystem === 'EPSG:4326') {
|
||||
position = {
|
||||
x: degrees.lng,
|
||||
y: degrees.lat,
|
||||
z: degrees.alt
|
||||
}
|
||||
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;'>经度:${degrees.lng.toFixed(6)}°</p><p style='margin: 0;'>维度:${degrees.lat.toFixed(6)}°</p><p style='margin: 0;'>海拔:${degrees.alt.toFixed(2)} m</p></div>`
|
||||
// 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;'>经度:${degrees.lng.toFixed(6)}°</p><p style='margin: 0;'>维度:${degrees.lat.toFixed(6)}°</p><p style='margin: 0;'>海拔:${degrees.alt.toFixed(2)} m</p></div>`
|
||||
switch (positionType || '度') {
|
||||
case '度':
|
||||
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;'>经度:${degrees.lng.toFixed(6)}°</p><p style='margin: 0;'>维度:${degrees.lat.toFixed(6)}°</p><p style='margin: 0;'>海拔:${degrees.alt.toFixed(2)} m</p></div>`
|
||||
break;
|
||||
case '度分':
|
||||
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;'>经度:${proj.degreesToDMS(degrees.lng, true)}</p><p style='margin: 0;'>维度:${proj.degreesToDMS(degrees.lat, true)}</p><p style='margin: 0;'>海拔:${degrees.alt.toFixed(2)} m</p></div>`
|
||||
break;
|
||||
case '度分秒':
|
||||
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;'>经度:${proj.degreesToDMS(degrees.lng, false)}</p><p style='margin: 0;'>维度:${proj.degreesToDMS(degrees.lat, false)}</p><p style='margin: 0;'>海拔:${degrees.alt.toFixed(2)} m</p></div>`
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
let result = tools.convert([{ x: degrees.lng, y: degrees.lat, z: degrees.alt }], 'EPSG:4326', coordinateSystem)
|
||||
|
||||
Reference in New Issue
Block a user