2

I have a .NET application dependent on ArcGIS 9.3.1 which I am upgrading to ArcGIS 10.

I have an AxMapControl sat in a panel in a split container on a tab. The Dockstyle is set to Fill.

Since upgrading to ArcGIS 10 from 9.3.1, the painting of the map inside the map control has become inconsistent.

The initial size of the map as painted is 'wrong' and the map ends up only filling, say, half the panel, and a second vertical scrollbar appears beside the map. This second scrollbar is a glitch; you cannot use it, and it is eventually painted over. The issue with the the map seems to be painting only: all other information presented (for example in the legend) is as if the map were painted correctly across the whole panel.

After a few operations (such as zooming in/out etc.) the map painting seems to 'catch up' and the map is painted correctly, filling the whole panel. This 'catching up' seems to get faster each time I run the application which leads me to suspect some sort of timing or caching issue.

There is no consistency about when the problem manifests. Sometimes adjusting the screen resolution affects it, other times not.

This seems to be a problem internal to the control. Does anyone have a workaround (other than reverting to the 9.3.1 DLLS)?

UPDATE: I have tried the following without success:

0

4 Answers 4

1

Try Isolating the problem. If you create a new form add a split control, drop a map control in to one side of it, then reference an mxd in the map control and run the form does the MapControl refresh properly?

I tried this exact thing upon reading your question, and it works fine out of the box for me. If it does for you, you could start adding pieces of your code to your test application until you can reproduce the error in the sample application.

1
  • Thank you M.D. An update: the problem only manifests concretely at one screen resolution: 1680x1050! Curiouser and curiouser... Commented Feb 23, 2015 at 9:03
1

Following M.D.'s prompt to isolate the problem, I removed all the event handlers from my map control, thus effectively paring it back to the core ArcGIS functionality. The map painting issue disappeared. I then added the event handlers back in one-by-one to isolate the problem.

The problem appears to be a bug in the ArcGIS control where if a map layer is inserted in the code for the OnExtentUpdated event handler, this seems to disrupt the painting of the map and the appearance of the painted map may not reflect the updated extent.

void mapAxMapControl_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e) { ... // Need to check if grid size needs to change if (e.sizeChanged) { ... IMapLayers mapLayers = (IMapLayers)mapControl.Map; mapLayers.InsertLayer(gridLayerHander.Layer, false, 1): ... } ... }

I moved the map layer insertion code to the less appropriate OnViewRefreshed event handler, for which there may be a performance penalty as the code is executed more often - especially as there is no sizeChanged property to check.

1
  • Although this works, I have supplied another answer, which I prefer, and accepted that one. Commented May 20, 2015 at 8:56
1

When the form is resized at runtime, the PageLayoutControl and MapControl do not automatically resize. To resize the controls so that they always fill the extent of the form, anchor the controls to the form. If the PageLayoutControl or MapControl contains a lot of data, redrawing this data while the form is resized can be costly. To increase performance, suppress the data redraw until the resizing is complete. During the resize, a stretched bitmap draws instead.

  1. Anchor the MapControl to the top, left, and bottom of its container
  2. Add ResizeBegin event handler to the MapControl:
private void MapViewer_ResizeBegin(object sender, EventArgs e)
{
    //Suppress data redraw and draw bitmap instead.
    axMapControl1.SuppressResizeDrawing(true, 0);
}
  1. Add Form_ResizeEnd event handler as well:
private void MapViewer_ResizeEnd(object sender, EventArgs e)
{
    //Stop bitmap draw and draw data.
    axMapControl1.SuppressResizeDrawing(false, 0);
}
4
  • 1
    Helpful comments. The application I am working with already suppresses the redraw in the fashion that you described. I have explicitly anchored the MapControl on all four sides and that has not corrected this particular issue. Commented Feb 23, 2015 at 12:59
  • 1
    Accoriding to this topic, Are you changing the DefaultWindowLocation? What about this link? Commented Feb 26, 2015 at 10:15
  • Some good suggestions here. I found the link you suggested and tried the fixed earlier but was not successful! I'll update my question with the new findings. Commented Feb 26, 2015 at 10:26
  • We are already using the DefaultWindowLocation. Commented Feb 26, 2015 at 10:34
0

Summary

The IScreenDisplay interface has a ScaleContents property; set this to true

Background

As this question reveals, ESRI changed the default behaviour of the map control at ArcGIS 10.

Less redrawing in data view

In previous versions of ArcMap, if you changed the size of the ArcMap display while working in data view, either by resizing the ArcMap window or by docking/undocking/resizing a dockable window, by default your map was completely redrawn to fit inside the available display area. So the scale changed and the extent stayed the same (although you may have seen some extra geographic coverage based on how well the extent fit inside the new shape of the display area). At version 10, the default drawing behavior in data view has been changed so that when the display size is changed, your map is no longer completely redrawn to fit inside the display. Instead, the scale stays the same and the extent will change. If you make the display bigger, you'll see a larger geographic extent, and vice versa.

This has the performance advantage that the portion of the display unaffected by resizing doesn't need to be redrawn at all. For example, if you close a docked window, only the portion of the display that was obscured by the window needs to be redrawn. It is also easier to work with the display because geographic features on your map don't move around as you dock and undock windows. Features on your map remain in the same location in the display until you manually pan or zoom the map.

(src: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_s_new_for_map_display_and_navigation/00qp0000001w000000/)

Resolution

You can reverse this change by using the IScreenDisplay interface to set the ScaleContents property to true. This can be set once the map is loaded into the control.

For me, the line of code would read:

mapControl.ActiveView.ScreenDisplay.ScaleContents = True;

This restores the old map redrawing behaviour - and as a side-effect, cures the redrawing problem explained here!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.