mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
472 stars 131 forks source link

InterpolateBuilder missing build() method? #2007

Open op27no2 opened 1 year ago

op27no2 commented 1 year ago

Hi Mapbox,

Trying to get interpolations and expressions to work in Java with v10. Trying to follow the example found here, but for me interpolate builder has no Build method to even try to work this out? https://github.com/mapbox/mapbox-maps-android/blob/main/app/src/main/java/com/mapbox/maps/testapp/examples/java/RuntimeStylingJavaActivity.java

Trying to accomplish the equivalent of my v9 code. mStyle.addLayer(new FillExtrusionLayer("course", "extrusion").withProperties( fillExtrusionColor(interpolate( linear(), get("hr"), stop(0, rgb(18,196,0)), stop(130, rgb(252,251,87)), stop(150, rgb(255,186,33)), stop(170, rgb(255,0,0)), stop(195, rgb(50,0,0)) )), fillExtrusionOpacity(0.5f), fillExtrusionHeight(get("height"))

Which I'm trying something like the following, but there appears to be no Expression.Stop etc. Was trying to see if the InterpolateBuilder or ExpressionBuilder could create stops as in the example, but I can't figure it out - these don't appear to actually have .build() methods available?!? Also not sure how to add the get("") parameter to the interpolateBuilder. All I see for availble methods are .linear(), .exponential(), and .cubicbezier().

          FillExtrusionLayer extrusionLayer = new FillExtrusionLayer("course", "extrusion");
          extrusionLayer.fillExtrusionColor(interpolateBuilder.**build()**)  ////NO BUILD() AVAILABLE??
          extrusionLayer.fillExtrusionOpacity(0.5f);
          extrusionLayer.fillExtrusionHeight(Expression.get(literal("height")));
          LayerUtils.addLayer(mStyle,mLayer);
ank27 commented 1 year ago

hi @op27no2 , i can see there is build() method for Expression.InterpolatorBuilder, see here for example https://github.com/mapbox/mapbox-maps-android/blob/v10.10/app/src/main/java/com/mapbox/maps/testapp/examples/java/RuntimeStylingJavaActivity.java#L291-L312. And you can use interpolateBuilder.stop same as used above.