1

I was obtaining the street, city and country details by passing the latitde and longitude values to the following URL: http://maps.google.com/maps/geo?q="+la+","+lo;. However, this has suddenly stopped working as I now get a returned status code 610 instead of 200. I googled and I came across the fact that Google has deprecated the older version with version V3 and the recommended use is to update to this version. The new URL will be something like this;

http://maps.googleapis.com/maps/api/geocode/json?latlng=25.34041,-55.489864&sensor=false

However, I am completely at lost how to use this? What is the Google API Key? Where should I obtain this from. Earlier I was using the above mentioned URL and imported the following into my project:

import org.json.me.JSONArray;
import org.json.me.JSONObject;

Please help how to proceed with this?

Sarah
  • 1,895
  • 2
  • 21
  • 39
  • This has been addressed many times and http://stackoverflow.com/a/15289007/2110460 has some information and links for more information – Rafe Mar 18 '13 at 07:37
  • 1
    https://developers.google.com/maps/documentation/javascript/tutorial#api_key – Sam R. Mar 18 '13 at 07:37
  • @Rafe yes I read that link first before posting the question. I needed help upgrading it. I understood the cause of it. Thanks anyways. – Sarah Mar 18 '13 at 07:39
  • @SamRad thanks, indeed helpful. I'll check it right away. – Sarah Mar 18 '13 at 07:40
  • how can I pass this URL "http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false" to obtain the address? This does not require a Google API key? How would it work. I am unable to proceed. – Sarah Mar 18 '13 at 07:46
  • 1
    Nearly, you need to take the "or false" off the end. Just leave it as sensor=true or sensor=false – Rafe Mar 18 '13 at 07:49
  • Thanks @Rafe, I did remove the false earlier as well. Was getting "Zero Results". However its working now. Seems no status code is returned now; just an "OK" status. – Sarah Mar 18 '13 at 07:55

1 Answers1

1

You are requesting a correct URL but your latlong values may be invalid. I request URL:

http://maps.googleapis.com/maps/api/geocode/json?latlng=25.34041,-55.489864&sensor=false

Results.

{
   "results" : [],
   "status" : "ZERO_RESULTS"
}

Requested with differnt latlong but same URL:

http://maps.googleapis.com/maps/api/geocode/xml?latlng=51.962146,7.602304&sensor=false"



{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Rishon-Le-Zion-Ring",
               "short_name" : "K6",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "North Rhine-Westphalia",
               "short_name" : "NRW",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Germany",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "48149",
               "short_name" : "48149",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "Rishon-Le-Zion-Ring, 48149 Münster, Germany",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 51.96354080,
                  "lng" : 7.602404200000001
               },
               "southwest" : {
                  "lat" : 51.96109890,
                  "lng" : 7.601790299999998
               }
            },
            "location" : {
               "lat" : 51.96233620,
               "lng" : 7.602270099999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 51.96366883029150,
                  "lng" : 7.603446230291501
               },
               "southwest" : {
                  "lat" : 51.96097086970850,
                  "lng" : 7.600748269708497
               }
            }
         },
         "types" : [ "route" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "48149",
               "short_name" : "48149",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "administrative_area_level_3", "political" ]
            },
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "North Rhine-Westphalia",
               "short_name" : "NRW",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Germany",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "48149 Münster, Germany",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 51.9846220,
                  "lng" : 7.6245910
               },
               "southwest" : {
                  "lat" : 51.9381030,
                  "lng" : 7.57505310
               }
            },
            "location" : {
               "lat" : 51.96236820,
               "lng" : 7.595598700000001
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 51.9846220,
                  "lng" : 7.6245910
               },
               "southwest" : {
                  "lat" : 51.9381030,
                  "lng" : 7.57505310
               }
            }
         },
         "types" : [ "postal_code" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "North Rhine-Westphalia",
               "short_name" : "NRW",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Germany",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Münster, Germany",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 52.06001970,
                  "lng" : 7.774361699999999
               },
               "southwest" : {
                  "lat" : 51.84015110000001,
                  "lng" : 7.473832599999999
               }
            },
            "location" : {
               "lat" : 51.96066490,
               "lng" : 7.62613470
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 52.06001970,
                  "lng" : 7.774361699999999
               },
               "southwest" : {
                  "lat" : 51.84015110000001,
                  "lng" : 7.473832599999999
               }
            }
         },
         "types" : [ "locality", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Münster",
               "short_name" : "Münster",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "North Rhine-Westphalia",
               "short_name" : "NRW",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Germany",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Münster, Germany",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 52.47498539999999,
                  "lng" : 8.320101899999999
               },
               "southwest" : {
                  "lat" : 51.48078280,
                  "lng" : 6.386867199999999
               }
            },
            "location" : {
               "lat" : 51.94711969999999,
               "lng" : 7.584531999999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 52.47498539999999,
                  "lng" : 8.320101899999999
               },
               "southwest" : {
                  "lat" : 51.48078280,
                  "lng" : 6.386867199999999
               }
            }
         },
         "types" : [ "administrative_area_level_2", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "North Rhine-Westphalia",
               "short_name" : "NRW",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Germany",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "North Rhine-Westphalia, Germany",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 52.53146959999999,
                  "lng" : 9.461634900000002
               },
               "southwest" : {
                  "lat" : 50.3227010,
                  "lng" : 5.86634250
               }
            },
            "location" : {
               "lat" : 51.43323669999999,
               "lng" : 7.661593799999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 52.53146959999999,
                  "lng" : 9.461634900000002
               },
               "southwest" : {
                  "lat" : 50.3227010,
                  "lng" : 5.86634250
               }
            }
         },
         "types" : [ "administrative_area_level_1", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Germany",
               "short_name" : "DE",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Germany",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 55.0583470,
                  "lng" : 15.04189620
               },
               "southwest" : {
                  "lat" : 47.27011150,
                  "lng" : 5.86634250
               }
            },
            "location" : {
               "lat" : 51.1656910,
               "lng" : 10.4515260
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 55.0583470,
                  "lng" : 15.04189620
               },
               "southwest" : {
                  "lat" : 47.27011150,
                  "lng" : 5.86634250
               }
            }
         },
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}
Munawar
  • 2,588
  • 2
  • 26
  • 29
  • Thanks @Needo, I managed to get it working. The coordinates are correct though. I got the "Zero Results" earlier but now it is returning the correct data with the same coordinates. – Sarah Mar 18 '13 at 11:30