Skip to content

Commit

Permalink
Only load the Mapbox reference layer when the style is ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
zestyping committed Jul 19, 2019
1 parent 8c89784 commit 1bbd778
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ public class MapboxMapFragment extends org.odk.collect.android.mapboxsdk.MapFrag
String path = config.getString(KEY_REFERENCE_LAYER);
referenceLayerFile = path != null ? new File(path) : null;
if (map != null) {
map.setStyle(getDesiredStyleBuilder());
loadReferenceOverlay();
map.setStyle(getDesiredStyleBuilder(), style -> {
loadReferenceOverlay();
});
}
}

Expand All @@ -223,7 +224,11 @@ private Style.Builder getDesiredStyleBuilder() {
.withTransition(new TransitionOptions(0, 0, false));
}

/** Updates the map to reflect the value of referenceLayerFile. */
/**
* Updates the map to reflect the value of referenceLayerFile. Because this
* involves adding things to the map's Style, call this only after the Style
* is fully loaded, in setStyle()'s OnStyleLoaded callback.
*/
private void loadReferenceOverlay() {
clearOverlays();
if (referenceLayerFile != null) {
Expand Down

0 comments on commit 1bbd778

Please sign in to comment.