What API method provides a drawing of city borders?

Using the Google Maps API v3, how can I geocode the name of a city and return a map with an outline of the result? it is usually a political entity with strict boundaries, for example, a city, municipality, etc.

Which API method should be used?

+7
google-maps
source share
2 answers

There is currently no API (which is currently) that provides this data.

Promotion Request

+3
source share

I think you will need Tiger / Line files as indicated in this answer . You can use the data to generate polygons . Use Geocoder.geocode to search for city names. Here's the promise-based function I'm using:

  function locateAddress(address) { var deferred = $q.defer(); if(!address) { $q.resolve(null); return; } var geocoder = new google.maps.Geocoder(); var a = address; if(_.isObject(a)) { a = (a.line1 || '') + ' ' + (a.city || '') + ' ' + (a.state || '') + ' ' + (a.zip || ''); } geocoder.geocode({ 'address' : a}, function(results, status) { if(status === 'ZERO_RESULTS') { deferred.resolve(null); return; } var c = results[0].geometry.location; deferred.resolve({latitude: c.lat(), longitude: c.lng()}); }, function(err) { deferred.reject(err); }); return deferred.promise; } 
+1
source share

All Articles