New google maps geocoder

The new Google Maps Geocoder!

In September 2020, Google announced a new version of the Geocoder API, which is designed to provide more accurate and efficient geocoding results. Here are some key changes and improvements:

New Geocoder API

The new Geocoder API is a RESTful API that allows you to geocode addresses and retrieve geographic coordinates (latitude and longitude) for a given location. The API is designed to be more scalable and efficient than the previous version.

Key Improvements

  1. Improved accuracy: The new Geocoder API uses more advanced algorithms and data sources to provide more accurate geocoding results.
  2. Faster response times: The API is designed to return results faster, with response times typically under 100ms.
  3. More flexible query parameters: The API allows you to specify more query parameters, such as language, region, and component filtering.
  4. Support for more address formats: The API supports a wider range of address formats, including international addresses and non-standard address formats.
  5. Enhanced error handling: The API provides more detailed error messages and error codes to help you troubleshoot issues.

New Geocoder API Endpoints

The new Geocoder API has two main endpoints:

  1. geocode: This endpoint is used to geocode a single address or a batch of addresses.
  2. reverse: This endpoint is used to reverse geocode a set of coordinates (latitude and longitude) to retrieve the corresponding address.

Example Request

Here's an example request to the geocode endpoint:

GET https://maps.googleapis.com/maps/api/geocode/json
 ?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
  &key=YOUR_API_KEY

Example Response

Here's an example response from the geocode endpoint:

{
  "results": [
    {
      "address_components": [
        {
          "long_name": "1600",
          "short_name": "1600",
          "types": ["street_number"]
        },
        {
          "long_name": "Amphitheatre Parkway",
          "short_name": "Amphitheatre Pkwy",
          "types": ["route"]
        },
        {
          "long_name": "Mountain View",
          "short_name": "Mountain View",
          "types": ["locality", "political"]
        },
        {
          "long_name": "Santa Clara County",
          "short_name": "Santa Clara",
          "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"]
        }
      ],
      "formatted_address": "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
      "geometry": {
        "location": {
          "lat": 37.4224764,
          "lng": -122.0842499
        },
        "location_type": "ROOFTOP",
        "viewport": {
          "northeast": {
            "lat": 37.4238264,
            "lng": -122.0829009
          },
          "southwest": {
            "lat": 37.4218264,
            "lng": -122.0859009
          }
        }
      },
      "place_id": "ChIJj61dQgK6j4AR4R6cQ7b7Q",
      "types": ["street_address"]
    }
  ],
  "status": "OK"
}

Conclusion

The new Google Maps Geocoder API is a significant improvement over the previous version, offering more accurate and efficient geocoding results. If you're building a location-based application, I recommend using the new Geocoder API to take advantage of its improved features and performance.