Export map to PDF - graphics not appearing

2204
4
11-11-2013 05:51 PM
KerriParker
New Contributor
I'm having an issue with our ArcObjects code for exporting a map to PDF. There is a section of code that adds graphics on to the map (polygons, lines, text etc). This seems to work fine for the first map generated after the map service is started, but on subsequent prints the markup does not get displayed on the map. This code worked previously but no we've converted it to run as an SOE on ArcGIS Server.

The code in question:

             
            // IMap map, IGraphicElements graphicElements

            GraphicUtil.GetGraphicsContainer(map).DeleteAllElements(); // clear any previous markup

            _logger.Debug("Add graphic elements to container");
            IGraphicsContainer graphicsContainer = GetGraphicsContainer(map);
            graphicsContainer.Reset();
            for (int i = 0; i < graphicElements.Count; i++)
            {
                IElement element = graphicElements.get_Element(i) as IElement;
                _logger.Debug("Adding geometry type: " + element.Geometry.GeometryType.ToString());
                graphicsContainer.AddElement(element, 0);
            }

            ((IActiveView)map).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

        ...

        public static IGraphicsContainer GetGraphicsContainer(IMap map)
        {
            return (IGraphicsContainer)map;
        }



If I take out the DeleteAllElements the markup stays on the map between requests but any new markup doesn't get added.
If I restart the map service, then it will add the markup on the next request, then not add anything after that.

In the ArcGIS Server logs I can see the following items which indicates nothing is being drawn, even though the graphic elements have been correctly added to the graphics container in the code (as far as I can tell)

INFO3 End of the graphics drawing.
INFO3 Graphic count: 0.
INFO3 Beginning of the graphics drawing.


Any ideas?

thanks,
Rowan
0 Kudos
4 Replies
deleted-user-VeC5jUIlNXtq
Occasional Contributor III
Definitely just tossing a guess out, but with a bit of previous knowledge behind it.

Doesn't partial refresh need to be called twice, once before and once after an "action" ? I'm not sure if that would solve your problem, but it's just something that caught my eye (though I could be mistaken).

Edit: I should add that, in my mind, you'd have partial refresh, then your code, then the partial refresh that's existing already. I only have experience with desktop code, so I might be wrong when it comes to Server side.
0 Kudos
KerriParker
New Contributor
Doesn't partial refresh need to be called twice, once before and once after an "action" ? I'm not sure if that would solve your problem, but it's just something that caught my eye (though I could be mistaken).


Thanks, tried that but it didn't seem to make any difference. Does it need to be the same type of partial refresh i.e. esriViewDrawPhase.esriViewGraphics?
0 Kudos
LeoDonahue
Occasional Contributor III
You should be calling graphicsContainer.next somewhere in your code.

Or take out this line:   graphicsContainer.Reset();
0 Kudos
KerriParker
New Contributor
You should be calling graphicsContainer.next somewhere in your code.

Or take out this line:   graphicsContainer.Reset();


No difference. I'm not retrieving anything from the graphics container anyway, just adding elements.
0 Kudos