2

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.

b.p
  • 31
  • 6
  • I think this [SO question](http://stackoverflow.com/questions/9644452/verify-if-a-point-is-land-or-water-in-google-maps) can answer your question. – KENdi Jun 11 '16 at 08:52
  • Possible duplicate of [Verify if a point is Land or Water in Google Maps](https://stackoverflow.com/questions/9644452/verify-if-a-point-is-land-or-water-in-google-maps) – stuyam Jul 17 '17 at 14:00

1 Answers1

0

You can filter results of reverse geocoding by result type and location type. In result type you can look for natural_feature and location type should be GEOMETRIC_CENTER or APPROXIMATE to exclude any ROOFTOP address that can be close to given point on the land.

Please have a look at the following request:

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

The first two items in response are:

  • North Atlantic Ocean (type: natural_feature, place ID: ChIJeQ3JDsMo3QoRBGVpwFckZUQ)
  • Atlantic Ocean (type: natural_feature, place ID: ChIJ_7hu48qBWgYRT1MQ81ciNKY)

Now if I execute the same request for the point on the land:

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

The first result will be 'Drum Point Rd, Brick, NJ 08723, USA' of type route.

Hope it helps.

xomena
  • 31,125
  • 6
  • 88
  • 117
  • It worked for me but it took some time to write using java client. Thanks:) – b.p Jun 14 '16 at 04:54
  • Hello @xomena it was working fine before. But now, when I was trying to revise it, I am getting Zero_results by using the above url. Does google maps have restricted it? or am I doing any mistake? Please let me know regarding this – b.p Sep 20 '16 at 08:43
  • I'm not sure if there are changes on Google side. I can see that there is a [feature request](https://code.google.com/p/gmaps-api-issues/issues/detail?id=4759) similar to your question. It looks like there is a recent activity in this FR. – xomena Sep 21 '16 at 08:29