1
votes

I use Mapbox Tileset API and generated a custom tileset (it's a huge 400MB of GeoJSON data) uploaded to Mapbox servers, and added to our style in the studio as a custom fill layer.

This way I can show our custom areas (as polygons) of the world with green (visited) and red (remaining) locations with using expressions only.

I would like to tell if a point (GPS coordinate) is within a polygon of the tileset source/layer and which one, even if the app is in the background (GPS tracking is running in the background and I would like to notify the user when they are within a polygon).

Using queryRenderedFeatures would be great, but unfortunately, it doesn't work when the app is in the background or the user's position is outside of the current viewport.

Is there any solution to get the list of the features at a GPS coordinate even if it's outside of the viewport?

Another requirement is that, it should work when the device is offline, so the Tilequery API won't help.

Downloading the offline data of our style with a limited zoom range working perfectly, I can see my custom source-layer (polygons) even if the device is offline.

So I think there should be a way to query the tileset-source when the device is offline too.

Currently, I generate a simplified GeoJSON file and use it with turf@points-within-polygon when the device is offline, but there're gaps, sometimes polygons are covering each other (due to the simplifying) etc... if I make the tolerance level lower the file is going to be too large to download and store it offline, so this is not really a solution just a poor workaround.

Can I make a PIP (point-in-polygon) query for a custom Tileset source even outside of the viewport, when the app is in the background and the device is offline?

1

1 Answers

1
votes

Assuming this is your actual question:

Can I make a PIP (point-in-polygon) query for a custom Tileset source even outside of the viewport, when the app is in the background and the device is offline?

If the device is offline, then any solution that requires fetching tiles on demand (like a tileset in Mapbox-GL or TileQuery) is out.

You said storing the whole GeoJSON is out, because it's too big.

I think the remaining solution is to generate a single-zoom-level tileset and store it locally, then query it with something like query-mbtiles.