0
votes

This old API syntax:

https://maps.googleapis.com/maps/api/geocode/json?address=L12+3TS%2c%2bUK&sensor=false&client=XYZ&signature=XYZ

should return the latitude and longitude given a UK postcode. It returns:

{
  "Status": {
    "code": 620,
    "request": "geocode",
    "error_message": "The Geocoding API v2 has been turned down on September 9th, 2013. The Geocoding API v3 should be used now. Learn more at https://developers.google.com/maps/documentation/geocoding/"
  }
}

which is fair enough. I studied this but cannot find the new syntax. Can someone help me out please? Ideally, I would also like to be able to obtain the latitude and longitude given a uk address string. Thanks.

1

1 Answers

0
votes
https://maps.googleapis.com/maps/api/geocode/json?address=L12+3TS%2c%2bUK&sensor=false

is working for me (I removed the client & signature info), giving the following result:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "L12",
               "short_name" : "L12",
               "types" : [ "postal_code_prefix", "postal_code" ]
            },
            {
               "long_name" : "Liverpool",
               "short_name" : "Liverpool",
               "types" : [ "postal_town" ]
            },
            {
               "long_name" : "Merseyside",
               "short_name" : "Mersyd",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Royaume-Uni",
               "short_name" : "GB",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Liverpool, Merseyside L12, Royaume-Uni",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 53.4605852,
                  "lng" : -2.8675854
               },
               "southwest" : {
                  "lat" : 53.4183146,
                  "lng" : -2.9233403
               }
            },
            "location" : {
               "lat" : 53.43679479999999,
               "lng" : -2.8881009
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 53.4605852,
                  "lng" : -2.8675854
               },
               "southwest" : {
                  "lat" : 53.4183146,
                  "lng" : -2.9233403
               }
            }
         },
         "partial_match" : true,
         "types" : [ "postal_code_prefix", "postal_code" ]
      }
   ],
   "status" : "OK"
}

So the problem may be around your client parameters.