getfromLocation return 海洋名称

getfromLocation return ocean or sea name

我正在 Android 中开发反向地理编码功能。 当我使用来自 Google API 的地理编码器 class 执行 getFromLocation(0, 0, 1) 时,例如调用它 returns ZERO RESULTS 并且地址长度为零。 但是例如,当我转到网络上的 Google 地图并右键单击位置 0,0 时,它显示 "Atlantic Ocean"。当我在 Android.

的 Google 地图应用程序中放置图钉时,这也有效

有没有办法从坐标 0,0 以编程方式获取 "Atlantic Ocean" 或类似的东西?当我说 0,0 时,它也适用于海中央的其他坐标。

是的,有一种方法可以得到坐标对应的海的名字。我所做的是使用 Google 地图 Javascript API 然后根据请求我添加了 result_type=natural_feature 代表水体和沙漠地址类型。添加这将 return 坐标中最近的水体。 Javascript 可以使用 Webview 集成到 android 上。

这是我的两个请求的请求和回复:

第一个请求类似于 getFromLocation(0,0,1)

要求:

https://maps.googleapis.com/maps/api/geocode/json?latlng=0,0&key=YOUR_API_KEY

回复:

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

对于使用 natural_feature 的下一个请求。

要求:

https://maps.googleapis.com/maps/api/geocode/json?latlng=0,0&result_type=natural_feature&key=YOUR_API_KEY

回复:

{
   "results" : [
  {
     "address_components" : [
        {
           "long_name" : "Atlantic Ocean",
           "short_name" : "Atlantic Ocean",
           "types" : [ "natural_feature", "establishment" ]
        }
     ],
     "formatted_address" : "Atlantic Ocean",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : 68.6187515,
              "lng" : 20
           },
           "southwest" : {
              "lat" : -83.0204773,
              "lng" : -83.21609509999999
           }
        },
        "location" : {
           "lat" : -14.5994134,
           "lng" : -28.6731465
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : 68.6187515,
              "lng" : 20.0000001
           },
           "southwest" : {
              "lat" : -83.0204773,
              "lng" : -83.21609509999999
           }
        }
     },
     "place_id" : "ChIJ_7hu48qBWgYRT1MQ81ciNKY",
     "types" : [ "natural_feature", "establishment" ]
  },
  {
     "address_components" : [
        {
           "long_name" : "Equator",
           "short_name" : "Equator",
           "types" : []
        }
     ],
     "formatted_address" : "Equator",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : 0,
              "lng" : 180
           },
           "southwest" : {
              "lat" : 0,
              "lng" : -180
           }
        },
        "location" : {
           "lat" : 0,
           "lng" : 0
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : 0.00134898029150203,
              "lng" : 180
           },
           "southwest" : {
              "lat" : -0.00134898029150203,
              "lng" : -180
           }
        }
     },
     "place_id" : "ChIJ9f-dgJ14AHARMp45pd8HMhs",
     "types" : []
  },
  {
     "address_components" : [
        {
           "long_name" : "Virgo",
           "short_name" : "Virgo",
           "types" : []
        }
     ],
     "formatted_address" : "Virgo",
     "geometry" : {
        "bounds" : {
           "northeast" : {
              "lat" : 14.3954258,
              "lng" : 47.853012
           },
           "southwest" : {
              "lat" : -22.9842321,
              "lng" : -5.6577015
           }
        },
        "location" : {
           "lat" : -4.294403099999999,
           "lng" : 21.0976553
        },
        "location_type" : "APPROXIMATE",
        "viewport" : {
           "northeast" : {
              "lat" : 14.3954258,
              "lng" : 47.853012
           },
           "southwest" : {
              "lat" : -22.9842321,
              "lng" : -5.6577015
           }
        }
     },
     "place_id" : "ChIJ3dT5sNUyHxoRJjQnMK1jABU",
     "types" : []
  }
   ],
   "status" : "OK"
}