谷歌地图中第三方纬度和经度不匹配

时间:2013-11-22 17:10:14

标签: javascript jquery google-maps

我有一个外部json,我试图在谷歌地图上叠加。整体管道工作正常。

生成地图。迭代数据,并通过读取坐标放置标记。但是当我看地图时,地图上的坐标就会消失。数据集不能错,我可以就此发表意见。是否需要进行一些调整才能使这个东西相互映射。这是我的代码

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { height: 100% }
    </style>
    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
    <script type="text/javascript">
      var map;
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(40.748433, -73.985655),
          zoom: 11,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("map_canvas"),
            mapOptions);
      }
    </script>
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script> 
  </head>
  <body onload="initialize()">
    <div id="map_canvas" style="width:100%; height:100%"></div>
    <script type="text/javascript">
      $(document).ready(function() {
      var image = 'http://soumghosh.com/otherProjects/doitt/images/marker.png';
        $.getJSON("http://data.cityofnewyork.us/resource/jfzu-yy6n.json", function(json1) {
          $.each(json1, function(key, data) {
            var latLng = new google.maps.LatLng(data.facility_address.latitude, data.facility_address.longitude); 
            // Creating a marker and putting it on the map
            var marker = new google.maps.Marker({
                position: latLng,
                title: data.title,
                icon:image
            });
            marker.setMap(map);
          });
        });
      });
    </script>
  </body>
</html>

0 个答案:

没有答案