从形状谷歌地图获取位置数据

时间:2016-05-19 18:56:58

标签: google-maps

我正在使用谷歌地图在地图上绘制形状。我想输出一个zip代码数组,但我找不到关于如何从api获取输出的示例或文档。我正在使用形状来圈选城市,我想最终从形状中返回一组邮政编码。暂时的任何位置数据表示都是可以接受的。我可以稍后处理转换它。我无法弄清楚如何从多边形形状输出位置数据。

我的目标是使用我的代码制作一个形状,然后能够导出形状中的所有邮政编码。 enter image description here

<!DOCTYPE html>
<html>
  <head>
    <title>HireMaster: Select Location</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      #map {
        height: 100%;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script>
      // This example requires the Drawing library. Include the libraries=drawing
      // parameter when you first load the API. For example:
      // <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=drawing">

      function initMap() {
        var map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 38, lng: 265},
          zoom: 5,
          mapTypeId: google.maps.MapTypeId.HYBRID
        });

        var drawingManager = new google.maps.drawing.DrawingManager({
          drawingMode: google.maps.drawing.OverlayType.POLYGON,
          drawingControl: true,
          drawingControlOptions: {
            position: google.maps.ControlPosition.TOP_CENTER,
            drawingModes: [





            ]
          },
          markerOptions: {icon: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png'},
          circleOptions: {
            fillColor: '#ffff00',
            fillOpacity: 1,
            strokeWeight: 5,
            clickable: false,
            editable: true,
            zIndex: 1

          }
        });
        drawingManager.setMap(map);
      }

    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDzUfosWJzaDKzYuffioH8liWWmbdPzwAQ&libraries=drawing&callback=initMap"
         async defer></script>
  </body>
</html>

0 个答案:

没有答案