I am developing a geovisualization data map that would plot the map of different colors depending on different number values. And, would want to have the number values be visualized on top of the circles too (it is a data of air pollution in a road circling around a route). The problem is when the two layers SymbolLayer and CircleLayer are applied at the same time they crash the mobile app, which does not work. I tried testing out only one of the layers they work, only when both are applied they crash. Is there a possibility for both layer tow work where the colored circle is present and the number value label is too? Also, I am using data stored in Tilesets. Below is the image link of the app. Cannot post images yet since this is my first time using StackOverflow.
//Map View
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
mapboxMap.setStyle(Style.LIGHT, new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
style.addSource(new VectorSource(
VECTOR_SOURCE_ID,
"http://api.mapbox.com/v4/"+TILESET_KEY+".json?access_token=" + Mapbox.getAccessToken()
));
SymbolLayer label =new SymbolLayer(TILESET_LAYER_ID, VECTOR_SOURCE_ID);
label.setSourceLayer(VECTOR_SOURCE_ID);
label.withProperties(
textField(get("gaslvl_PM")), //This contains the number values
textSize(17f),
textColor(Color.RED),
textVariableAnchor(
new String[]{TEXT_ANCHOR_TOP, TEXT_ANCHOR_BOTTOM, TEXT_ANCHOR_LEFT, TEXT_ANCHOR_RIGHT}),
textJustify(TEXT_JUSTIFY_AUTO),
textRadialOffset(0.5f)
);
label.setFilter(all(
//This is to filter out the multiple rounds in the route of one full roundtrip.
//To prevent the same data from the same area to overlap.
eq(literal("roundtrip_number"), literal(roundT_val))));
style.addLayer(label);
CircleLayer circleLayer = new CircleLayer(TILESET_LAYER_ID, VECTOR_SOURCE_ID);
circleLayer.setSourceLayer(VECTOR_SOURCE_ID);
circleLayer.withProperties(
circleRadius(
interpolate(
exponential(1.75f),
zoom(),
stop(12, 2f),
stop(22, 180f)
)),
circleColor(
match(
get(TILESET_LAYER_ID),rgb(0, 0, 0),
stop("0", COLOR_GREEN),
stop("1", COLOR_GREEN),
stop("2", COLOR_GREEN),
stop("3", COLOR_GREEN),
stop("4", COLOR_GREEN)
//Didn't add the rest of the "stop colors" since it's 500 lines.
));
circleLayer.setFilter(all(
eq(literal("roundtrip_number"), literal(roundT_val))
//eq(literal("date"), literal(Date.valueOf(date_val)))
));
style.addLayer(circleLayer);
}
});
}
});