How to render points on a map with a text label and a custom bitmap image

1085
4
Jump to solution
05-02-2023 02:15 AM
ChrisNightingale
Emerging Contributor

Hi all,

Please excuse the simple questions but still learning how to use the ArcGIS Pro 3.1 SDK.

I'm trying to render some points on a map which use a text label and custom 32x32 bitmap image to represent the marker (instead of a simple dot). I get the impression I need to use a specific renderer but can't work out which sort and am equally not sure I have used the correct feature class and/or feature layer (I'm still trying to learn the terminology!)

So I have created successfully created a GeoDatabase with the points I want to render. I have managed to get the points displaying on the map using some of the following code (sorry it's not complete otherwise there is too much!) but now need to get a text label and custom icon displayed:

// Create the feature class
ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Point, SpatialReferences.WGS84);
FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassName, fieldDescriptions, shapeDescription);
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
schemaBuilder.Create(featureClassDescription);

if (schemaBuilder.Build())
{
  FeatureClass featureClass = geodatabase.OpenDataset<FeatureClass>(featureClassName);

  // Create the feature layer
  var layerParams = new FeatureLayerCreationParams(featureClass);
  var layer = LayerFactory.Instance.CreateLayer<FeatureLayer>(layerParams, map);
}

So how do I render the points using a custom bitmap graphic?  Am I correct in using the Feature Class and Feature Layer like this?

I see that I can call "SetRenderer" on the feature layer but not sure how to create the appropriate renderer which will result in the text label and custom bitmap?

0 Kudos
2 Solutions

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

Look at the Esri ArcGIS Pro SDK community sample Symbology .

To create point symbol from picture you can use sample below:

//The following file formats can be used to create the marker: DAE, 3DS, FLT, EMF, JPG, PNG, BMP, GIF
CIMMarker markerFromFile = await QueuedTask.Run(() => SymbolFactory.Instance.ConstructMarkerFromFile(@"C:\Temp\fileName.dae"));

CIMPointSymbol pointSymbolFromFile = SymbolFactory.Instance.ConstructPointSymbol(markerFromFile);

More info in API reference  https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic4098.html 

View solution in original post

Wolf
by Esri Regular Contributor
Esri Regular Contributor

Not sure if you are aware of this, but you can do this with out-of-box ArcGIS Pro features.   You can create your own symbols (from images) as described here:  Create or modify symbol images—ArcGIS Pro | Documentation

Then you can enable the 'Unique Values' renderer to display the images using an attribute in your shapefile or geodatabase.  To display any text (text from an attribute column) you can turn on labelling for that column.   I used the community sample data: "Interacting with Maps.aprx" for the screenshot below:

Wolf_0-1683042421040.png

 

 

View solution in original post

4 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Look at the Esri ArcGIS Pro SDK community sample Symbology .

To create point symbol from picture you can use sample below:

//The following file formats can be used to create the marker: DAE, 3DS, FLT, EMF, JPG, PNG, BMP, GIF
CIMMarker markerFromFile = await QueuedTask.Run(() => SymbolFactory.Instance.ConstructMarkerFromFile(@"C:\Temp\fileName.dae"));

CIMPointSymbol pointSymbolFromFile = SymbolFactory.Instance.ConstructPointSymbol(markerFromFile);

More info in API reference  https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic4098.html 

ChrisNightingale
Emerging Contributor

Many thanks - that's the sort of thing I'm looking for - just never sure where to start looking for this kinda of stuff!

I also ended up referring to the code in the `https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/CIMExamples/Creat...` file found in the example project found in `https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/CIMExamples`

So now I have some of our bitmap files being displayed as markers - but now need to work out how to set the transparency colour of the marker to get rid of the background colour

 

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Not sure if you are aware of this, but you can do this with out-of-box ArcGIS Pro features.   You can create your own symbols (from images) as described here:  Create or modify symbol images—ArcGIS Pro | Documentation

Then you can enable the 'Unique Values' renderer to display the images using an attribute in your shapefile or geodatabase.  To display any text (text from an attribute column) you can turn on labelling for that column.   I used the community sample data: "Interacting with Maps.aprx" for the screenshot below:

Wolf_0-1683042421040.png

 

 

ChrisNightingale
Emerging Contributor

Ahh that's probably just what I'm looking for as we do need to have variants of the symbols based on data in the geo database.  Thanks so much.

0 Kudos