Search code examples
phpgoogle-mapsoptimizationgoogle-maps-api-3geolocation

Optimizing Geographic Center in Google Maps with Respect to Travel Time if it Lies Within Water


So I calculated the geographic center of multiple points and now want to optimize the geographic center so that if it lies in a body of water I can find the land point that is still closest to the true center, but also the closest for the original points. I also need some help with detecting if the point is infact in water so if someone could include the google maps query code for that I would appreciate it greatly. I included my getdata.php page to show my calculations, and any help would be greatly appreciated. I am new to this stuff so spelt out explanations may be needed but again thanks for any help!


Solution

  • There is no good way with Google Maps API to know if a point is above water or not. To get the closest address (on land) for a point that is over water, you could use Reverse Geocoding. But to my experiment, sometimes the coordinates returned are not really the closest place on land, and this will not work for a point in the middle of the ocean.

    For more information, you can check the following question and answers: Verify if a point is Land or Water in Google Maps

    There is also a good webservice by Geonames that you can find here: http://www.geonames.org/export/web-services.html

    Especially the Find nearby and Extended Find nearby toponym / reverse geocoding which returns the ocean name in case it's over an ocean/sea. Try to register an account to play with it, because the demo account is usually over limit.

    Hope this helps.