0

I am planning a typical routes application for both Android and iOS, and there is something I can't replicate on Android. You can, in iOS, get some extra information about a particular point in a map by using CLPlacemark.ocean and CLPlacemark.inlandWater. Those two properties tell whether the point is over water and, in this case, the name of this water body (river X, lake Y or ocean Z)

Is there something in Google Maps API or Android SDK that might get close to that? I would be happy if only I could tell water from ground.

Thanks in advance!

P.S: sorry if iOS tag is not appropiate.

1 Answers1

0

The CLPlacemark is an iOS class, so you can not use this class in Android.

Android has a Geocoder class, it can return a list of Address objects. But the Address class does not have method to tell whatever a location is in a ocean or not.

One way is to use the Google Maps Geocoding API. If your address is in land, the result_type of the response will be something like "administrative_area". if you are in the sea, the response will be "natural_feature". You can see the return type from this its documentation.

However the Geocoding API is a Javascript API, if you want to use it in Android, you can do a HTTP URL request, sample request:

  URL requestUrl = new URL("https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=API_KEY" );
 HttpURLConnection connection = (HttpURLConnection)requestUrl.openConnection();
 connection.setRequestMethod("GET");
 connection.connect();

then you can parse the JSON response, and find out whether a location is in a ocean or not. Alternatively, you can use Google's Java client library for your request, sample usage: https://developers.google.com/maps/documentation/webservices/client-library#usage

You can find more information about to use Geocoding API to determine see or land from these SO answers:

https://stackoverflow.com/a/3645696/4195406

https://stackoverflow.com/a/9644812/4195406

Community
  • 1
  • 1
ztan
  • 6,861
  • 2
  • 24
  • 44
  • Thanks ztan for the tips. I'll compare the XMLs for different locations to see what can I get from them. I see different nodes on them. – Adolfo I. C. Feb 26 '15 at 10:06