Arcgis-Android add labels to feature layer

4059
3
06-15-2015 08:20 AM
AneteFridrihsone
New Contributor II

Hello,

I am trying to figure out how to add labels to a feature layer in my ArcGISAndroid mobile application. I have seen labeingInfo(), but that as far as I understand that goes to ArcGISDynamicServiceLayer. I have seen featureLayer.setEnableLabels(true) but I cannot find a place where I can specify which field to use for labels and how labels would look like. Can somebody please advice?

I am actually having ArcGISFeatureLayer that I want to label. If there are solutions for that, it would be the best! But understanding how I can label feature layer will be helpful too.

Thanks!

3 Replies
MengyiGuo
Occasional Contributor

Hi Dian,

As you seen on this discussion: How to display label infomation

There are two ways to do this. If you are working with ArcGISFeatureLayer, then you need to set up labels in your data in ArcMap. You get what you set for labels before publishing, you can not specify fields in your Android code.

The second way to do it is using ArcGISDynamicMapServiceLayer. You may already notice that you can operate it with DrawingInfo.

LabelingInfo.setLabelExpression(String labelExpression) can help you choose the fields you want to show. Simply by controling the label expression, you can choose which fields to show the values of as labels, concatenate multiple fields, add a custom String, round numerical values, and more using the syntax outlined in the REST specification at http://resources.arcgis.com/en/help/rest/apiref/label.html

0 Kudos
AneteFridrihsone
New Contributor II

Hi Mengyi,

Thanks for answering! I have seen that discussion and read resources, but unfortunately using  ArcGISDynamicMapServiceLayer is not a good option. I guess I also didn't believe there is no simpler way for feature service implemented in API..

In the application I have polygons which have name field (which should be used for labels). By single-tap user can access features info and edit polygons name. I need the label to update according to these changes.

So, the only option to make this happen is to have two layers -  feature service for editing and map for labeling, correct? As suggested in discussion "How to display label information". In your opinion, do you think that will drag performing speed down a lot? That polygon cluster is fairly dense. Also, do you know if labels are rendered statically or dynamically (do they rotate if I rotate the mapView)?

Thanks a lot for all the help!


0 Kudos
MengyiGuo
Occasional Contributor

The other way I can think of is using TextSymbol to create a label by yourself. When you rotate the mapView, I think every layer on the map will be redrew as well as the mapview itself.

0 Kudos