Select to view content in your preferred language

How to add labels on Android application.

1516
7
04-10-2017 03:10 PM
ThomasSaldana
Emerging Contributor

Hello,

I created a map document on ArcMap, and I created polygons in it. I assigned numbers to the polygons, and i am able to see them as labels in ArcMap. However, when i download the layers on my android application, the labels of the polygons do not show. Does anyone know how to display labels from ArcMap on Android ? Thanks! 

0 Kudos
7 Replies
AlexanderNohe1
Honored Contributor

Hi Thomas Saldana‌,

I would look into turning on labeling via the feature layer method setLabelsEnabled(booelan enabled):

FeatureLayer| arcgis-android 

I believe that documentation link should put you on the correct path.

Thanks,

Alexander

0 Kudos
ThomasSaldana
Emerging Contributor

Oh okay, thank you. 

Do i add that right after I set a layer?

This is how i am setting a layer in the android application: 

mFeatureServiceUrl = ".../arcgis/rest/services/SecondPrototypetest/MapServer/2";//getString(R.string.FirstFloors);set all floors in the basement level, one by one
mFeatureLayer = new ArcGISFeatureLayer(mFeatureServiceUrl, ArcGISFeatureLayer.MODE.ONDEMAND);//leave
mMapView.addLayer(mFeatureLayer);
0 Kudos
ThomasSaldana
Emerging Contributor

I am also using the 

ArcGISFeatureLayer class, but I am not sure if it makes a difference. 

I get an error. It cannot resolve the method. 

0 Kudos
AlexanderNohe1
Honored Contributor

Hi thomassldn‌,

I was under the assumption that you were working with Runtime version 100, not runtime version 10.2.x.  I will need to go and revisit the previous runtime version and see if I can come up with something.

Thanks,

Alexander

0 Kudos
AlexanderNohe1
Honored Contributor

Hi Thomas Saldana‌,

Perhaps you could try using FeatureLayer | ArcGIS Android 10.2.9 API and using the setLabelsEnabled(boolean) to turn on labels for your feature.  This would take a feature table as the constructor for a feature layer and you should be able to construct the feature table from a GeodatabaseFeatureServiceTable.  I hope this helps!

Thanks,

Alexander

0 Kudos
ThomasSaldana
Emerging Contributor

Hi Alexander, 

Thank you for the information. I have tried your suggestion, like this: 

public ArcGISFeatureLayer mFeatureServiceUrl = ".../arcgis/rest/services/SecondPrototypetest/MapServer/2";
mFeatureLayer = new ArcGISFeatureLayer(mFeatureServiceUrl, ArcGISFeatureLayer.MODE.ONDEMAND);//leave
mMapView.addLayer(mFeatureLayer2);

GeodatabaseFeatureServiceTable layertable = new GeodatabaseFeatureServiceTable("http://...:6080/arcgis/rest/services/SecondPrototype/MapServer/2", 158);
FeatureLayer layer = new FeatureLayer(layertable);
layer.setEnableLabels(true);

However, it did not seem to work. I think i am doing it incorrectly.

Is this what you were thinking?

Thank you for your time.

0 Kudos
ThomasSaldana
Emerging Contributor

Sorry, I meant like this: 

public ArcGISFeatureLayer mFeatureLayer;
mFeatureServiceUrl = ".../arcgis/rest/services/SecondPrototypetest/MapServer/2";
mFeatureLayer = new ArcGISFeatureLayer(mFeatureServiceUrl, ArcGISFeatureLayer.MODE.ONDEMAND);//leave
mMapView.addLayer(mFeatureLayer2);

GeodatabaseFeatureServiceTable layertable = new GeodatabaseFeatureServiceTable("http://roomquest.research.cse.csusb.edu:6080/arcgis/rest/services/SecondPrototype/MapServer/158", 158);
FeatureLayer layer = new FeatureLayer(layertable);
layer.setEnableLabels(true);
0 Kudos