Creating an extent indicator

469
2
Jump to solution
03-24-2022 05:01 AM
starenix
New Contributor

I'm creating a map layout in C#. I have 2 map frames; one is the main frame, the other is an area of interest frame that needs an extent indicator. I'm able to create everything on the layout, except I can't seem to figure out how to plug the CIMExtentIndicator definition into the CIMMapFrame Element.

Here's the relevant code:

 

 

//MapFrame Creation
                Coordinate2D ll = new Coordinate2D(0.25, 1.3);
                Coordinate2D ur = new Coordinate2D(10.75, 8);
                Envelope mapEnv = EnvelopeBuilder.CreateEnvelope(ll, ur);
                //AOI map frame
                Coordinate2D ll_aoi = new Coordinate2D(10.05, .25);
                Coordinate2D ur_aoi = new Coordinate2D(10.72, 1.25);
                Envelope mapEnv_aoi = EnvelopeBuilder.CreateEnvelope(ll_aoi, ur_aoi);

                MapFrame newMapFrame = LayoutElementFactory.Instance.CreateMapFrame(newLayout, mapEnv, newMap);
                newMapFrame.SetName("Main Map Frame");
                MapFrame AOI = LayoutElementFactory.Instance.CreateMapFrame(newLayout, mapEnv_aoi, aoiMap);
                var cimAOI = AOI.GetDefinition() as CIMMapFrame;
                AOI.SetName("AOI Frame");
                
                CIMStroke extentOutline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 1.0, SimpleLineStyle.Solid);
                CIMPolygonSymbol extentPoly = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlackRGB, SimpleFillStyle.Null, extentOutline);
                var extent = new CIMExtentIndicator
                
                {
                    SourceMapFrame = "Main Map Frame",
                    Symbol = extentPoly.MakeSymbolReference(),
                    
                };

                cimAOI.ExtentIndicators[0] = extent;               
                AOI.SetDefinition(cimAOI); //exception thrown: the Object is null

 

 

 

I notice that the CIMExtentIndicator property on the CIMMapFrame element contains square brackets [], meaning it requires an index integer, but I'm just not sure how to form the correct syntax.

I'm using VS2019. No build issues occur before running the code. If I comment out the extent indicator code, everything works perfectly.

0 Kudos
1 Solution

Accepted Solutions
CharlesMacleod
Esri Regular Contributor

try something like this:

 

 var extent = new CIMExtentIndicator {
   SourceMapFrame = "Main Map Frame",
   Symbol = extentPoly.MakeSymbolReference(),
 };
 cimAOI.ExtentIndicators = new List<CIMExtentIndicator> { extent}.ToArray();

View solution in original post

2 Replies
CharlesMacleod
Esri Regular Contributor

try something like this:

 

 var extent = new CIMExtentIndicator {
   SourceMapFrame = "Main Map Frame",
   Symbol = extentPoly.MakeSymbolReference(),
 };
 cimAOI.ExtentIndicators = new List<CIMExtentIndicator> { extent}.ToArray();
starenix
New Contributor

Yes! That works perfectly, thank you so much Charles!

0 Kudos