World Imagery labels for an offline map

1720
7
Jump to solution
06-30-2021 12:25 AM
FatmaAkdemir
Occasional Contributor II

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?

0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

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 

View solution in original post

7 Replies
LukeSmallwood
Esri Contributor

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 

FatmaAkdemir
Occasional Contributor II

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.

0 Kudos
LukeSmallwood
Esri Contributor

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.

 

FatmaAkdemir
Occasional Contributor II

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?

0 Kudos
LukeSmallwood
Esri Contributor

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.

 

Hope that helps,

 

Luke

FatmaAkdemir
Occasional Contributor II

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.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Have you made sure to append the label json to the layer and enable labels on the layer? https://github.com/Esri/arcgis-runtime-samples-qt/blob/main/ArcGISRuntimeSDKQt_CppSamples/DisplayInf... 

0 Kudos