How to programmatically clone a MapBox layer?

I am loading a style with an existing one CircleLayer, and I would like to programmatically add another such layer with a similar style (let's say the same, except for a different color). His geodata will also be created programmatically.

I could not find a simple API for layer cloning.

But even if I do something like:

CircleLayer oldLayer, newLayer = ...;
newLayer.withProperties(
    PropertyFactory.circleColor(Color.parseColor("#e55e5e")),
    oldLayer.getCircleStrokeColor()
);

Setting the color of the environment (as a literal) works, but to set the color of the stroke (taken from another layer) I get:

09-25 20:59:20.783 18014-18014/com.example.client E/mbgl: {example.client}[JNI]: Error setting property: circle-stroke-color property not found

I checked it is oldLayercorrectly initialized and oldLayer.getCircleStrokeColor()returns the correct one PropertyValue. What am I missing?

+4
source share

Source: https://habr.com/ru/post/1686368/


All Articles