我正在使用Google Maps API处理Android应用,将位置信息作为JSON返回 . 但是,当我按纬度和经度搜索时,Google Maps API有时会返回NO结果 . 为了确保我没有做错事,我搜索了这样的城市“idhna”
https://maps.googleapis.com/maps/api/geocode/json?address=idhna&key=XXXXXXXXXXXXXXXXXX
它返回
{
"results" : [
{
"address_components" : [
{
"long_name" : "Idhna",
"short_name" : "Idhna",
"types" : [ "locality", "political" ]
}
],
"formatted_address" : "Idhna",
"geometry" : {
"location" : {
"lat" : 31.557252,
"lng" : 34.979243
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 31.5667594,
"lng" : 34.9952504
},
"southwest" : {
"lat" : 31.5477436,
"lng" : 34.9632356
}
}
},
"place_id" : "ChIJjfxiM8TuAhURpQKxXGq5lDo",
"types" : [ "locality", "political" ]
}
],
"status" : "OK"
}
但是当我从结果中复制纬度和经度并尝试搜索时
https://maps.googleapis.com/maps/api/geocode/json?latlng=31.557252,34.979243&key=XXXXXXXXXXXXXXXXXXXXXXXXX
结果是
{
"results" : [],
"status" : "ZERO_RESULTS"
}
1 回答
看起来这是此API可以访问的数据的限制,并且无论您是否获得坐标数据,它基本上都会受到影响 .
测试Sumaya,它显示结果:https://maps.googleapis.com/maps/api/geocode/json?address=sumaya
但是,情况与您问题中的url相同,它显示lat / lon没有结果:
https://maps.googleapis.com/maps/api/geocode/json?latlng=31.523946,34.968806
就像测试一样,我尝试了附近城市边境的Beit Guvrin:
https://maps.googleapis.com/maps/api/geocode/json?address=BeitGuvrin
哪个返回坐标:
从lat / lon返回有效结果:
https://maps.googleapis.com/maps/api/geocode/json?latlng=32.1298801302915,34.8555745
我还测试了Keidar,它成功地显示了从地址查询返回的坐标的结果 .
因此,它基本上是命中或未命中,具体取决于API对给定位置的数据量 .