Identify the name of the streets contained in a polygon

4

I have the following polygon below:

function initialize() {
  var bounds = new google.maps.LatLngBounds();
  var i;

  var polygonCoords = [
     new google.maps.LatLng(-23.554548, -46.607911),
     new google.maps.LatLng(-23.556043, -46.595058),
     new google.maps.LatLng(-23.564403, -46.593942),
      new google.maps.LatLng(-23.567884, -46.604757)
  ];
  

  for (i = 0; i < polygonCoords.length; i++) {
     bounds.extend(polygonCoords[i]);
  }

  var map = new google.maps.Map(document.getElementById("map_canvas2"), {
    zoom: 14,
    center: bounds.getCenter(),
    mapTypeId: "roadmap"
  });


  var sp_mooca = new google.maps.Polygon({
    paths: polygonCoords,
    strokeColor: '#0000ff',
    strokeOpacity: 0.8,
    strokeWeight: 2,
    fillColor: '#0000ff',
    fillOpacity: 0.35
  });
  sp_mooca.setMap(map);
 
  
}
#map {
  height: 100%;
}
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script><bodyonload="initialize()">
  <div id="map_canvas2" style="height: 100vh; width:100vw"></div>
</body>

Is it possible to identify the names of all the streets contained in a polygon in Google Maps? If yes, how?!

    
asked by anonymous 22.10.2017 / 17:44

1 answer

0

I believe the API does not have a method that returns addresses in a polygon.

Has containsLocation that checks if the coordinate is inside the polygon. If your intention is to extract the addresses of the polygon to check if it hits with any address you have, you can do the opposite: verify that your addresses belong to the polygon.

And has geocode that returns the address from a coordinate. Then you can loop through coordinates inside the polygon by getting the addresses. But this way you can reach the limit of queries easily. Code sample .

I think in a way, depending on the size of the polygon, this would feature mass extraction of the API, which is prohibited by the terms of use. You can use OpenStreetMap for this, and even download the database (you can select only one region) and make the geodata manipulations without restrictions.

    
22.10.2017 / 18:23