How to update the source style in mapbox, now I do it by first removing the layers, then the source and adding it again, but with a larger number of geojsons you can clearly see that the my “refresh” disappears and reappears after a while.
Below is the code so far:
Value geoJsonSourceValue = Value.fromJson(sourceJson.toString()).getValue();
mapView.getMapboxMap().removeStyleLayer("fill-layer");
mapView.getMapboxMap().removeStyleSource("c-source");
mapView.getMapboxMap().addStyleSource("c-source", geoJsonSourceValue);
String layerFillJson = "{"
+ ""id": "fill-layer","
+ ""type": "fill","
+ ""source": "c-source","
+ "}";
Value layerFillValue = Value.fromJson(layerFillJson).getValue();
mapView.getMapboxMap().addStyleLayer(layerFillValue, null);