v2.0 ArcGISLayerInfo & Legend

2124
1
07-09-2012 08:24 AM
RobertoCodarini
New Contributor
Hi!

I'm trying ArcGISLayerInfo.getLegend() method to build a table of contents, the method retrieveLegendInfo() on the ArcGISDynamicMapServiceLayer object returns always false.

Do you have any suggestion?

Best Regards
Rob
0 Kudos
1 Reply
EgorFedorov
New Contributor

Try to call retrieveLegendInfo() in separate thread after layer is loaded, like this:

mapView.setOnStatusChangedListener(new OnStatusChangedListener() {

                    @Override

                    public void onStatusChanged(Object o, STATUS status) {

                        if (status == STATUS.LAYER_LOADED) {

                            if (o instanceof ArcGISDynamicMapServiceLayer) {

                                //retrieving legend info

                                new AsyncTask<Void, Void, Void>() {

                                    @Override

                                    protected Void doInBackground(Void... voids) {

                                        dynamicLayer.retrieveLegendInfo();

                                        return null;

                                    }

                                }.execute();

                            }

                        }

                    }

                });

0 Kudos