android - How to color polyline/GeoJSON line by speed/altitude in MapBox? -


i want draw gps track on map (mapbox) , color points speed or altitude. need custom drawer track.

mapbox android sdk provides example of drawing polyline customized style: https://www.mapbox.com/android-sdk/examples/add-a-geojson-line/ still static style, not driven data.

this part of example point of interest:

linelayer.setproperties(       propertyfactory.linedasharray(new float[]{0.01f, 2f}),       propertyfactory.linecap(property.line_cap_round),       propertyfactory.linejoin(property.line_join_round),       propertyfactory.linewidth(5f),       propertyfactory.linecolor(color.parsecolor("#e55e5e"))     ); 

propertyfactory methods have implementations function parameter. suspect search for. no manual or example of using implementations found.

any ideas custom drawer?

i develop xamarin.android app in c# using mapbox android sdk ported java.

upd: function type definition seen in assembly metadata following:

[javatypeparameters(new[] { "t" })] [register("com/mapbox/mapboxsdk/style/layers/function", donotgenerateacw = true)] public class function : java.lang.object {     protected function(intptr javareference, jnihandleownership transfer);      public virtual float base { get; }     protected override intptr thresholdclass { get; }     protected override type thresholdtype { get; }      [javatypeparameters(new[] { "t" })]     [register("stop", "(flcom/mapbox/mapboxsdk/style/layers/property;)lcom/mapbox/mapboxsdk/style/layers/function$stop;", "")]     public static stop invokestop(float @in, property output);      [javatypeparameters(new[] { "i", "o" })]     [register("com/mapbox/mapboxsdk/style/layers/function$stop", donotgenerateacw = true)]     public class stop : java.lang.object     {         protected stop(intptr javareference, jnihandleownership transfer);          [register("in")]         public java.lang.object in { get; set; }         [register("out")]         public java.lang.object out { get; set; }         protected override intptr thresholdclass { get; }         protected override type thresholdtype { get; }     } } 

upd2: use c# things bit different java. here code going use:

linelayer linelayer = new linelayer("linelayer", "line-source");         linelayer.setproperties(new property[] {            propertyfactory.linecolor("**what should here?**"),            propertyfactory.visibility(property.visible),            propertyfactory.linewidth((java.lang.float)3f)         }); 

could provide bit more information on how storing data? geojson file? there few different functions offered data driven styling believe might interested in categorical one.

using single geojson code snippet below styles 2 lines depending on data's property field (one blue , other red):

linelayer lineslayer = new linelayer(constants.line_layer, constants.line_source).withproperties(       propertyfactory.linecolor(         property(           "color",           categorical(             stop("red", propertyfactory.linecolor(color.parsecolor("#f7455d"))),             stop("blue", propertyfactory.linecolor(color.parsecolor("#33c9eb")))           ))       ),       propertyfactory.visibility(property.visible),       propertyfactory.linewidth(3f)     );      // add linelayer map     mapboxmap.addlayer(lineslayer); 

hopefully points in right direction!


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -