How to view ArcGIS layer legend in Android? -
i have 3 layers (drainage, bridge , slope) in arcgis feature server. android app view each layer on arcgismap
, , set layer visibility based on checkbox tick. using arcgis runtime sdk android (version 100.1).
my question is, possible view layers' legend feature server layers dialog? means replace 3 cute icons.
android app (layers dialog in middle)
feature server (layers' legend on left)
thank in advance!
update
thanks falldownhill's suggestion use create swatch! working code
// loop each layer (int x=0; x<featurelayer.length; x++) { try { // try each layer legend final listenablefuture<list<legendinfo>> layerlegend = featurelayer[x].fetchlegendinfosasync(); final int finalx = x; layerlegend.adddonelistener(new runnable() { @override public void run() { try { // each layer legend list<legendinfo> legendinfo = layerlegend.get(); symbol legendsymbol = legendinfo.get(0).getsymbol(); listenablefuture<bitmap> symbolswatch = legendsymbol.createswatchasync(mainactivity.this, color.transparent); // set each layer legend bitmap symbolbitmap = symbolswatch.get(); imageview swatchimg = (imageview) drawerdialog.findviewbyid(layerimageviewid[finalx]); swatchimg.setimagebitmap(symbolbitmap); } catch (interruptedexception e) { //showmessage("animation interrupted"); } catch (executionexception e) { // deal exception during animation... } } }); } catch (exception e) { // ignore changing layer legend } }
android app (updated layers dialog desired legend in middle)
i think create swatch you're looking for.
just show 1 way use it:
float density = instrumentationregistry.getcontext().getresources().getdisplaymetrics().density; (featuretype type : featuretable.getfeaturetypes()) { (featuretemplate template : type.gettemplates()) { geometry geometry = //create whatever shape want swatch feature feature = featuretable.createfeature(template, geometry); symbol symbol = featurelayer.getrenderer().getsymbol(feature); listenablefuture<bitmap> symbolswatch = symbol.createswatchasync(24, 24, density,color,feature.getgeometry()); bitmap swatch = symbolswatch.get(); } }
Comments
Post a Comment