Google地图中的坐标显示不准确

时间:2014-10-21 10:55:32

标签: javascript html google-maps

我想在Google地图上的两个坐标之间画一条线。 我想使用的两个坐标是:

4738.3319,N 下, 的 01903.2312,E

4738.3219,N 下, 的 01903.7575,E

我已将这些转换如下:

47.383319 下, 的 19.032312

47.383219 下, 的 19.037575

我正在使用以下代码:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Simple Polylines</title>
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
    <script>
// This example creates a 2-pixel-wide red polyline showing
// the path of William Kingsford Smith's first trans-Pacific flight between
// Oakland, CA, and Brisbane, Australia.

function initialize() {
  var mapOptions = {
    zoom: 12,
    center: new google.maps.LatLng(47.383219, 19.037575),
    mapTypeId: google.maps.MapTypeId.TERRAIN
  };

  var map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);

  var flightPlanCoordinates = [
    new google.maps.LatLng(47.383319, 19.032312),
    new google.maps.LatLng(47.383219, 19.037575),

  ];
  var flightPath = new google.maps.Polyline({
    path: flightPlanCoordinates,
    geodesic: true,
    strokeColor: '#FF0000',
    strokeOpacity: 1.0,
    strokeWeight: 3
  });

  flightPath.setMap(map);
}

google.maps.event.addDomListener(window, 'load', initialize);

    </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>
</html>

我的问题是,谷歌地图在布达佩斯南部边界的哪个地方划线,当时他们应该大致指向北边界。此外,经度几乎是好的,它有一个较小的不准确度(约2公里),但纬度是绝对错误的。我需要至少15-20米的准确度。我使用的是错误的格式吗?

1 个答案:

答案 0 :(得分:1)

您的坐标可能是第一个数字为度数的格式,点数之前的两个数字是分钟,点之后的数字是分数的分数。也就是说,

4738.3319,N, 01903.2312,E

指北纬47度38.3319分,东经19度3.2312分。

要将这些转换为适合Google地图的十进制度数,您需要将分钟数除以60(因为每度数为60分钟),而不是100.这样就可以了

47 + 38.3319/60 = 47.638865 N, 19 + 3.2312/60 = 19.053853 E
实际上,它位于布达佩斯的北部。