nww04
nww04

Reputation: 1857

MapBox ability to detect if coordinates is on a body of water?

First of all, MapBox allows downloading off-line region. Well, downloading off-line region for the Pacific ocean doesn't really make sense. I was sent a ticket coming from the QA department to at least prevent user from ever downloading anything when the coordinates requested is on a body of water (doesn't really matter if it is a river, waterfalls, sewage what not). I have to prevent user accidentally downloading off-line regions that mostly composed of body of water (mostly oceans or seas).

I am creating an application for a client whose user base are seafarers and downloading off-line region can be costly. So my question is MapBox capable of detecting this without me ever using this hack?

Thanks!

Upvotes: 1

Views: 1261

Answers (1)

cammace
cammace

Reputation: 3168

You can query the map tiles directly without the need to make an API call. An example doing this is if you want to check the users center view port point.

LatLng center = mapboxMap.getCameraPosition().target;
final PointF pixel = mapboxMap.getProjection().toScreenLocation(center);
List<Feature> features = mapboxMap.queryRenderedFeatures(pixel, "water");

This will return a list of features with at least a size of 1 if the users currently looking at water, otherwise, it will have a size of 0.

Note that you can also do this considering the entire viewport area or any bounding box region for that matter.

Upvotes: 3

Related Questions