Is it possible to get the neighborhood of an address using google maps api or bing maps api?

10,056

Solution 1

Google Places API enables you to get neighborhood information. But the information got from the API have to use for Google Maps.

https://developers.google.com/places/documentation/

Solution 2

Yes, neighborhood is returned in the address_components[] array as part of the Geocoding API.

Google has a live demo app that shows off the Geocoding API. The neighborhood field is available for places that appear in cities which have neighborhoods.

Here's a simple example to fetch neighborhood data using the Python client for Google Maps:

import googlemaps

API_KEY = "YOUR_API_KEY"
gmaps = googlemaps.Client(key=API_KEY)
print gmaps.geocode('3027 16th St, San Francisco, CA 94103, United States')

This will print the following:

[{'address_components': [{'long_name': '3027',
                          'short_name': '3027',
                          'types': ['street_number']},
                         {'long_name': '16th Street',
                          'short_name': '16th St',
                          'types': ['route']},
                         {'long_name': 'Mission District',
                          'short_name': 'Mission District',
                          'types': ['neighborhood', 'political']},
                         {'long_name': 'San Francisco',
                          'short_name': 'SF',
                          'types': ['locality', 'political']},
                         {'long_name': 'San Francisco County',
                          'short_name': 'San Francisco County',
                          'types': ['administrative_area_level_2',
                                    'political']},
                         {'long_name': 'California',
                          'short_name': 'CA',
                          'types': ['administrative_area_level_1',
                                    'political']},
                         {'long_name': 'United States',
                          'short_name': 'US',
                          'types': ['country', 'political']},
                         {'long_name': '94110',
                          'short_name': '94110',
                          'types': ['postal_code']},
                         {'long_name': '3402',
                          'short_name': '3402',
                          'types': ['postal_code_suffix']}],
  'formatted_address': '3027 16th St, San Francisco, CA 94110, USA',
  'geometry': {'bounds': {'northeast': {'lat': 37.764927, 'lng': -122.4201635},
                          'southwest': {'lat': 37.7646504,
                                        'lng': -122.4203792}},
               'location': {'lat': 37.7647804, 'lng': -122.4202906},
               'location_type': 'ROOFTOP',
               'viewport': {'northeast': {'lat': 37.7661376802915,
                                          'lng': -122.4189223697085},
                            'southwest': {'lat': 37.76343971970851,
                                          'lng': -122.4216203302915}}},
  'place_id': 'ChIJxT0SpyN-j4ART07xF7G8NGE',
  'types': ['premise']}]

See the official Geocoding API Guide for more information.

Solution 3

You can download this example on Google https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform

var componentForm = {
  ...,
  neighborhood: 'short_name',
  ...,
};

In HTML table add

 <tr>
    <td class="label">Neighbourhood</td>
    <td class="wideField" colspan="3"><input class="field"
          id="neighborhood" disabled="true"></input></td>
 </tr>

You can see neighborhood information displayed after address is entered

Share:
10,056
perseverance
Author by

perseverance

Updated on June 13, 2022

Comments

  • perseverance
    perseverance almost 2 years

    Is it possible to get the neighborhood using either the Google Maps API or Bing Maps API? For example would it be possible to get the value of "Financial District" neighborhood for a search of the address in that neighborhood in San Francisco? If not, are there other resources online for this? Thanks!

  • nirvana74v
    nirvana74v about 6 years
    A comment like this & a down vote without providing enough details to reproduce your issue doesn't look good @Hamdan