• utm 转 经纬度坐标 cesium Ue4 CityEngine


    utm 转 经纬度坐标|
     

    1. html>
    2. <html lang="en">
    3. <head>
    4. <title>UTM to LatLng Conversiontitle>
    5. <meta charset="utf-8" />
    6. <style>
    7. body {
    8. font-family: Arial, sans-serif;
    9. margin: 20px;
    10. background-color: #f5f5f5;
    11. }
    12. h1 {
    13. font-size: 24px;
    14. margin-bottom: 20px;
    15. text-align: center;
    16. }
    17. form {
    18. max-width: 400px;
    19. margin: 0 auto;
    20. background-color: #ffffff;
    21. padding: 20px;
    22. border-radius: 5px;
    23. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    24. }
    25. p {
    26. font-size: 18px;
    27. margin-bottom: 10px;
    28. }
    29. label {
    30. display: inline-block;
    31. width: 120px;
    32. font-weight: bold;
    33. }
    34. input[type="number"] {
    35. width: 100%;
    36. padding: 10px;
    37. font-size: 16px;
    38. border: 1px solid #ddd;
    39. border-radius: 5px;
    40. }
    41. button {
    42. display: block;
    43. width: 100%;
    44. padding: 10px;
    45. font-size: 16px;
    46. font-weight: bold;
    47. color: #fff;
    48. background-color: #007bff;
    49. border: none;
    50. border-radius: 5px;
    51. cursor: pointer;
    52. }
    53. #result {
    54. font-weight: bold;
    55. font-size: 20px;
    56. margin-top: 20px;
    57. text-align: center;
    58. }
    59. #saveButton {
    60. margin-top: 20px;
    61. background-color: #28a745;
    62. }
    63. style>
    64. style>
    65. <script src="https://cdn.bootcdn.net/ajax/libs/proj4js/2.9.0/proj4-src.js">script>
    66. head>
    67. <body>
    68. <h1>UTM to LatLng Conversionh1>
    69. <form>
    70. <p>
    71. <label for="utmX">UTM X-coordinate:label>
    72. <input type="number" id="utmX" step="any" />
    73. p>
    74. <p>
    75. <label for="utmY">UTM Y-coordinate:label>
    76. <input type="number" id="utmY" step="any" />
    77. p>
    78. <button type="button" onclick="convertUTMToLatLng()">Convertbutton>
    79. form>
    80. <p>Converted LatLng:p>
    81. <p id="result">p>
    82. <button id="saveButton" type="button" onclick="saveToLocalStorage()">Save Coordinatesbutton>
    83. <script>
    84. const utmProjection = '+proj=utm +zone=49 +datum=WGS84 +units=m +no_defs';
    85. const utmXInput = document.getElementById('utmX');
    86. const utmYInput = document.getElementById('utmY');
    87. const resultElement = document.getElementById('result');
    88. // Load coordinates from local storage if available
    89. window.onload = function () {
    90. if (localStorage.getItem('utmX') && localStorage.getItem('utmY')) {
    91. utmXInput.value = localStorage.getItem('utmX');
    92. utmYInput.value = localStorage.getItem('utmY');
    93. }
    94. }
    95. let latLngRes = ''
    96. const convertUTMToLatLng = () => {
    97. const utmX = parseFloat(utmXInput.value);
    98. const utmY = parseFloat(utmYInput.value);
    99. if (isNaN(utmX) || isNaN(utmY)) {
    100. alert('Please enter valid UTM coordinates.');
    101. return;
    102. }
    103. // Define UTM projection object
    104. const utm = proj4(utmProjection);
    105. // Perform projection conversion
    106. const latLng = utm.inverse([utmX, utmY]);
    107. console.log(latLng,'latLng');
    108. latLngRes = `${latLng[0]}, ${latLng[1]}`
    109. // Update the displayed result
    110. resultElement.textContent = `${latLng[0]}, ${latLng[1]}`;
    111. // Save coordinates to local storage
    112. localStorage.setItem('utmX', utmX);
    113. localStorage.setItem('utmY', utmY);
    114. };
    115. const saveToLocalStorage = () => {
    116. const utmX = parseFloat(utmXInput.value);
    117. const utmY = parseFloat(utmYInput.value);
    118. if (isNaN(utmX) || isNaN(utmY)) {
    119. alert('Please enter valid UTM coordinates.');
    120. return;
    121. }
    122. // Save coordinates to local storage
    123. localStorage.setItem('utmX', utmX);
    124. localStorage.setItem('utmY', utmY);
    125. // 创建一个辅助元素用于复制文本
    126. var tempElement = document.createElement("textarea");
    127. tempElement.value = latLngRes;
    128. document.body.appendChild(tempElement);
    129. // 选择辅助元素的文本并复制
    130. tempElement.select();
    131. document.execCommand("copy");
    132. // 移除辅助元素
    133. document.body.removeChild(tempElement);
    134. alert("Text copied!");
    135. };
    136. script>

  • 相关阅读:
    font-spider 压缩字体使用
    数字安全设备制造有哪几种方式?
    恒运资本:股市板块轮动顺口溜?
    大规模ddos攻击事件,ddos攻击会暴露ip吗
    二叉树的存储结构
    商超仓库管理系统
    Ⅰ. C++基本使用
    Mpeg-Niacin 甲氧基-聚乙二醇-烟酸,Mpeg-NOTA甲氧基聚乙二醇-NOTA
    HTML的段落中怎么样显示出标签要使用的尖括号<>?
    图论09-桥和割点
  • 原文地址:https://blog.csdn.net/songJunFeng1/article/details/133992037