I am looking for a way to change the font size, style(Bold) and add a mask(Halo) through the sdk.
Hi Michael,
You should be able to adjust the settings of a MapFrame in a Layout using the SetCamera method. Check out the code snippets on this page of the API Reference guide: topic11124.html
Thanks!
Uma
Hi Uma,
Is there a way to get at the location settings of the mapframe in the layout through the sdk. I want to adjust the scale and the center x and y.
Michael Stranovsky
Spatial Database Administrator
EIT – Enterprise GIS
1660 Ringling Blvd, Sarasota, FL 34236
Office: 941-914-8373
Cell: 941-914-8373
Email: mstranov@scgov.net<mailto:mstranov@scgov.net>
Web: www.scgov.net<http://www.scgov.net/>
All email sent to and from Sarasota County Government
is subject to the public record laws of the State of Florida.
To learn more about Florida’s Sunshine Law click here<https://employeenet.scgov.net/Communications/SitePages/Public Records.aspx>.
<https://www.facebook.com/SarasotaCountyGovernment/> <https://twitter.com/SRQCountyGov/> <https://www.instagram.com/srqemergencyservices/> <https://www.youtube.com/user/sarasotacounty1> <http://www.linkedin.com/company/27399?goback=.fcs_GLHD_sarasotacountygovernment_false_2_2_2_2_2_2_2_2_2_2_2_2&trk=ncsrch_hits>
Okay thank you again
Hi Michael
The LabelClass' Expression property can be used. Like this:
theLabelClass<SPAN class="punctuation token">.</SPAN>Expression <SPAN class="operator token">=</SPAN> <SPAN class="string token">"$feature.POP2000"</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
Another thing you might find helpful while working with the CIM is to use the arcgis-pro-sdk-cim-viewer. This will give a view of all the CIM objects, properties that you can manipulate for what you need.
Thanks
Thank you, how would you change the label expression(field use for labeling)?
Thank you for your help. It worked like a charm. One more question though, how would you change the expression for the label?(the field used to label)
Hi
You can access the Feature Layer's LabelClasses and the TextSymbol through the CIM to accomplish this. Here is a snippet:
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">ChangeLabel</SPAN><SPAN class="punctuation token">(</SPAN>FeatureLayer lyr<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> lyrDefn <SPAN class="operator token">=</SPAN> lyr<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetDefinition</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> CIMFeatureLayer<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> listLabelClasses <SPAN class="operator token">=</SPAN> lyrDefn<SPAN class="punctuation token">.</SPAN>LabelClasses<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> textSymbol <SPAN class="operator token">=</SPAN> listLabelClasses<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>TextSymbol<SPAN class="punctuation token">.</SPAN>Symbol <SPAN class="keyword token">as</SPAN> CIMTextSymbol<SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//Gets the text symbol of the label class</SPAN> textSymbol<SPAN class="punctuation token">.</SPAN>FontStyleName <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Bold"</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//set font as bold</SPAN> textSymbol<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetSize</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">10</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//set font size</SPAN> <SPAN class="comment token">//Text symbol might not have a halo. </SPAN> <SPAN class="comment token">//So need to create a halo symbol (polygon with a solid fill layer)</SPAN> <SPAN class="keyword token">var</SPAN> haloFill <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">CIMSolidFill</SPAN> <SPAN class="punctuation token">{</SPAN> Enable <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">,</SPAN> Color <SPAN class="operator token">=</SPAN> ColorFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN>RedRGB<SPAN class="punctuation token">,</SPAN> ColorLocked <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//Define the array of Symbol layers (holds the halo solid fill only)</SPAN> <SPAN class="keyword token">var</SPAN> symbolLyrs <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">CIMSymbolLayer</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">{</SPAN> haloFill <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//Creates the Polygon symbol with the halo solid fill layer</SPAN> <SPAN class="keyword token">var</SPAN> haloSymbol <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">CIMPolygonSymbol</SPAN> <SPAN class="punctuation token">{</SPAN> SymbolLayers <SPAN class="operator token">=</SPAN> symbolLyrs <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//Assign this halo symbol and its size to the text symbol</SPAN> textSymbol<SPAN class="punctuation token">.</SPAN>HaloSymbol <SPAN class="operator token">=</SPAN> haloSymbol<SPAN class="punctuation token">;</SPAN> textSymbol<SPAN class="punctuation token">.</SPAN>HaloSize <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN> lyrDefn<SPAN class="punctuation token">.</SPAN>LabelClasses <SPAN class="operator token">=</SPAN> listLabelClasses<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToArray</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//Set the labelClasses back</SPAN> lyr<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetDefinition</SPAN><SPAN class="punctuation token">(</SPAN>lyrDefn<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//set the layer's definition</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.