JSON状态代码610

时间:2013-03-18 07:33:24

标签: google-maps geocoding google-geocoding-api

我通过将latitde和经度值传递到以下网址来获取街道,城市和国家/地区详细信息:http://maps.google.com/maps/geo?q="+la+","+lo;。然而,这突然停止工作,因为我现在得到返回的状态代码610而不是200.我googled并且我发现谷歌已经弃用版本V3的旧版本,推荐使用是更新到此版本。新的URL将是这样的;

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

然而,我完全迷失了如何使用它?什么是Google API密钥?我应该从哪里获得这个。之前我使用上面提到的URL并将以下内容导入我的项目:

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

请帮忙解决这个问题?

1 个答案:

答案 0 :(得分:1)

您正在请求正确的网址,但您的latlong值可能无效。 我请求网址:

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

结果。

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

请求不同的latlong但相同的网址:

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"
}