I have an offline map consisting of world imagery tiles. If we want to add city labels as markers and text items, which method should we follow? We have a shape file containing city texts and locations, would that be useful?
Hi @FatmaAkdemir - yes you could use your shapefile to add the labels to the basemap. The Basemap type has a referenceLayers property where you could append label layers etc. For your shapefile data you would:
- create a ShapefileFeatureTable using the path to the .shp file
- create a FeatureLayer using the shapefile feature table
- append the feature layer to the basemap's referenceLayers
Note that Esri also has services that would allow you to export offline tiles including labels. You could export the labels that way - but if you just want city locations, the shapefile data that you have may be best.
Hope that helps,
Luke
Hi @LukeSmallwood ,
I managed to explore the fields, and there is a "CITY_NAME" field that I want to display as label.
const QString labelJson(R"({"labelExpressionInfo":{"expression":"$feature.CITY_NAME"},"labelPlacement":"esriServerPolygonPlacementAlwaysHorizontal","symbol":{"angle":0,"backgroundColor":[255,255,255,60],"borderLineColor":[255,255,0,255],"borderLineSize":1,"color":[255,255,0,255],"font":{"decoration":"none","size":8,"style":"normal","weight":"normal"},"haloColor":[255,255,255,120],"haloSize":0.5,"horizontalAlignment":"center","kerning":false,"type":"esriTS","verticalAlignment":"middle","xoffset":0,"yoffset":0}})");
However no labels are displayed on the feature layer.
Hi @FatmaAkdemir - you can explore a shapefile with various packages (including ArcGIS Pro and also I think if you upload it to ArcGIS Online). In Runtime, you can examine the attributes of the shapefile feature table by inspecting the fields property of the feature table. That should let you check to see which field would best suit your needs.
Hi @LukeSmallwood , we managed to display city boundaries by using the shapefile but we couldn't find a way to extract the city names from shapefile. We want to add city names as a label to the feature layer. There is a CITY_NAME column in the .dbf file but should we instead explore the .shp file for city names? Is there a tool to see the list of attributes in the .shp file?
Hi @FatmaAkdemir - this group contains a number of services that incorporate a reference layer for labels https://www.arcgis.com/home/group.html?id=c61ab1493fff4b84b53705184876c9b0&view=list#content. You could see if one of those works for your use case.
Thanks for the answer @LukeSmallwood . Could you give us the link to export tiles with labels? We haven't decided yet about using the shapefile. Thanks in advance.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.