Closed nathanhollows closed 5 years ago
These lines in MapActivity
set fetch the locations. MapBox automatically fetches it using the URI, but it would also accept a string instead. The okhttp
library might be a simple way to fetch and cache this.
// Add a new source from the GeoJSON data and set the 'cluster' option to true.
try {
source = new GeoJsonSource("locations",
new URI("https://nuggetwatch.co.nz/locations"), // this line here
new GeoJsonOptions()
.withCluster(true)
.withClusterMaxZoom(14)
.withClusterRadius(50)
);
loadedMapStyle.addSource(source);
} catch (URISyntaxException uriSyntaxException) {
}
ee9f0cd stores the locations file in a cache for 24 hours. I'm not sure if it holds it indefinitely if the phone isn't internet connected. In case the connection fails it should still pull from a local copy if there is nothing else available
There's a race condition when loading the locations json file and building the map. The app occasionally loads the file first and tries to add it to the map before it is fully initialised. It can cause a crash on start up
Solved with 724b01311b52dcda68084108586723d72639eaee
To ensure the app is usable straight away without a wifi connection the location data should be stored locally and then cached in future. The location data is from nuggetwatch.co.nz/locations
Here's how it should work:
locations
or 'locations.json`locations
with nuggetwatch.co.nz/locations