Я указал цвета object2.addProperty("marker-colors", "#ffbf00");
в json, чтобы затем получить значение. withImage(ICON_ID, createBitMap(get("marker-color")))
Я буду использовать значение цвета в createBitmap (...)
здесь мой код
List<Feature> features = new ArrayList<>();
JsonObject object1 = new JsonObject();
object1.addProperty("title", "TEST1");
object1.addProperty("marker-color", "#c70024");
features.add(Feature.fromGeometry(
Point.fromLngLat(106.535033, -6.323488), object1));
JsonObject object2 = new JsonObject();
object2.addProperty("title", "TEST2");
object2.addProperty("marker-color", "#ffbf00");
features.add(Feature.fromGeometry(
Point.fromLngLat(106.897423, -6.277078), object2));
JsonObject object3 = new JsonObject();
object3.addProperty("title", "TEST3");
object3.addProperty("marker-color", "#00c753");
features.add(Feature.fromGeometry(
Point.fromLngLat(106.797217, -6.171958), object3));
затем
mapboxMap.setStyle(new Style.Builder().fromUri(CPN_STYLE)
.withSource(new GeoJsonSource(SOURCE_ID,
FeatureCollection.fromFeatures(features)))
.withImage(ICON_ID, createBitMap(get("marker-color")))
.withLayer(new SymbolLayer(LAYER_ID, SOURCE_ID)
.withProperties(
textField(get("title")),
iconImage(ICON_ID),
textSize(14f),
iconAllowOverlap(true),
iconIgnorePlacement(true),
textColor(get("marker-color")),
textJustify(TEXT_JUSTIFY_AUTO),
iconOffset(new Float[]{0f, -9f}))
), style -> {
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder()
.target(new LatLng(-6.323488, 106.535033))
.zoom(7)
.build()), 1000);
});
Ответ будет очень полезным. Спасибо