private void AddSanciangkoStreet(@NonNull Style style) {
style.addImage("sanciangko-street",
BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.floodicon)));
style.addSource(new GeoJsonSource("sanciangkoFlood1-source-id"));
style.addLayer(new SymbolLayer("sanciangkoFlood1-layer-id", "sanciangkoFlood1-source-id").withProperties(
iconImage("sanciangko-street"),
iconIgnorePlacement(true),
iconAllowOverlap(true),
iconSize(1f)
));
I need to hide this Symbol when my statusValue = 0 and appears again when statusValue = 1. Please help
Change visibilty propery to NONE/VISIBLE
:
public void updateLayer(final int statusValue) {
mapboxMap.getStyle(new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
Layer layer = style.getLayer("sanciangkoFlood1-layer-id");
if (layer != null) {
layer.setProperties(PropertyFactory.visibility(
statusValue == 0 ? Property.NONE : Property.VISIBLE
));
}
}
});
}