I am allowing my users to Export their polygons using a a form in which they select the polygon and hit export. This tool asks if the user would like to highlight the polygon with a certain color, and also buffer that polygon. The tool then exports a pdf layout or shows it on the screen. I have been able to allow for selection, load a saved layout, update the layout tags, move the camera, etc. This all happens in the background. However, when I try to add a selection overlay, or buffer overlay, it doesn't show up on the layout? I know I am adding the disposable overlay to the map, because I am not disposing it yet and I can see it?
//This highlights my geometry on my main map
CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(0, 0, 0, 50.0), 2.0, SimpleLineStyle.Solid);
CIMRGBColor BlueColor = ColorFactory.Instance.BlueRGB as CIMRGBColor;
IDisposable disposable = MapView.Active.AddOverlay(inItem.Geometry, SymbolFactory.Instance.ConstructPolygonSymbol(BlueColor, SimpleFillStyle.Solid, outline).MakeSymbolReference());
//Get the map frame element of the layout that I use, and replace the map
//This should have the disposable Overlay on it but it doesn't?
Layout layout = LayoutProjectItem.GetLayout();
MapFrame mapFrame = layout.FindElement("MapLayer") as MapFrame;
// Create PDF format with appropriate settings
PDFFormat PDF = new PDFFormat()
Resolution = 300,
OutputFileName = inExportFileName
This code is just a snipped of all of my code, but i essentially want to add a overlay to the map and export it. But it doesn't seem to be on the exported map?
Hello and thank you for your feedback.
Overlays are not persisted and in order for items to be exported they must be persisted. The solution is to create elements in a feature class. This is the same solution in the UI. MapNote (feature classes) are used in in place of graphics in a map view.
So is there an easy way to make some dummy or temp feature classes to add to a map? Something I could do locally on the users machine and not in the feature service. i would then add those layers to the map, add the buffer/highlight polygon, color them, and then export. Then i would have to clean them up afterwards. How could I make some temp polygon feature classes like you suggest here.
Adding MapNotes like in the UI may be a bit heavy handed because it builds many point, line and polygon feature classes. It might be best if you create/reference your own feature class and add the geometries. Check out the Geodatabase and Geometry ProSnippets.
Can you create a feature class on the fly like this? Or do I make a make a feature class and save it with the project, then reference it? Or do I make a feature service for just this need and reference it. I don't need the class for anything other than exporting, but I will need to label and color the values that I do add.
I am implementing the solution you discussed above.
- Creating a Export Polygon Feature Class
- Creating a layer file from that class that I color and label as I want
- Exporting Layer file and adding it to the content of my .proConfigX file
- When Exporting map, I add this feature layer file to a copy of my Active.Map
- Remove any existing Rows from that FeatureLayer (so the old ones don't show up if any)
- Add the new rows for the Shapes I want to see as overlays to my map
- Export the map and clean up.
This seems like it might work, as it lets me color the layer file and set its properties on the layer file itself and I don't have to do it in code. Then I just add the layer file to the map using the URI of the .proConfigX.
I haven't addressed the speed of efficiency of this process, or if by exporting the layer file when creating the template, if the Dataset will be a problem, because it will no longer be the original dataset.
Hey do you have code I can see to help me try this. I am also having this issue. The only thing is that i'm afraid it won't work for what i need. I am trying to use a graphic overlay to mask data I don't want to show in my export. Turning it into a feature class will likely result in the data not being masked. If I add a feature class over it now the data shows. The data is labels.
I personally have not tried it. All I know is that your overlays are not persisted and to persist the geometries you need a feature class. This is also the same in the UI. The development team is aware of the current limitation and is looking into a solution. If you just need a temporarly feature class, my approach would be to create a scratch feature class in the projects default GDB, add whatever geometries are needed, export, and then perhaps delete the feature class.
Im trying to do this in an effort to mask labels that are showing where I don't want them. Adding a feature class still doesn't cover the labels but graphic overlay does.