how to know whether a point is on land or water using google maps api

时间:2016-06-10 16:11:17

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

I want to know whether a point is on land or water using google maps geocoding api.

If I give my coordinate point as (40,-74) which is on water body, I am still getting address which is shown below.

the address is:1416 Highland Ave, Cinnaminson, NJ 08077, USA results[0].geometry.locationType:ROOFTOP results[0].types[0].toString():street_address(which has to be "natural_feature")

I am using java client library to do this. Anyone help me because I have strucked up here and has to submit my assignment where soon. Thanks in Advance.

1 个答案:

答案 0 :(得分:0)

您可以按结果类型和位置类型过滤反向地理编码的结果。在结果类型中,您可以查找natural_feature,并且位置类型应该是GEOMETRIC_CENTER或APPROXIMATE,以排除任何可以接近陆地上给定点的ROOFTOP地址。

请查看以下请求:

https://maps.googleapis.com/maps/api/geocode/json?latlng=40%2C-74&result_type=natural_feature&location_type=GEOMETRIC_CENTER%7CAPPROXIMATE&key=YOUR_API_KEY

回应的前两项是:

  • 北大西洋(类型:natural_feature,地点ID:ChIJeQ3JDsMo3QoRBGVpwFckZUQ)
  • 大西洋(类型:natural_feature,地点ID:ChIJ_7hu48qBWgYRT1MQ81ciNKY)

现在,如果我对陆地上的点执行相同的请求:

https://maps.googleapis.com/maps/api/geocode/json?latlng=40.044043%2C-74.124069&result_type=natural_feature&location_type=GEOMETRIC_CENTER%7CAPPROXIMATE&key=YOUR_API_KEY

第一个结果将是' Drum Point Rd,Brick,NJ 08723,USA'路线类型。

希望它有所帮助。