This project is read-only.

ExtentsChanged event to change the scale/point size

Jan 10, 2011 at 10:02 PM
Edited Jan 10, 2011 at 10:07 PM
In mapwindow 4 you can use use the axMap1_ExtentsChanged event to change the scale/point size of point layers like: 
 
 private void axMap1_ExtentsChanged(object sender, EventArgs e)
        {
            MapWinGIS.Extents ext = (MapWinGIS.Extents)axMap1.Extents;
            double scale = ext.xMax - ext.xMin;

            int startPointSize = pointSize;

            if (scale > 10000)
            {
                pointSize = 8;
                rutePointSize = 6;
            }.......
axMap1.set_ShapeLayerPointColor(handle, (UInt32)(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red)));
axMap1.set_ShapeLayerPointSize(handle, pointSize);

How is this done in dotSpartial?

In dotSpartial the event is ViewExtentsChanged 


Should this be done in my Categories or could it be done globally/layer wise


Jan 10, 2011 at 10:27 PM

Map1.ViewExtentsChanged is the event I think.  Map1.ViewExtents are the actual extents.

As  far as setting up the symbolizer, you need the layer.  So in other words, we don't have a method like the one above that is accessed on the map itself.  A structure like that doesn't lend itself to extensibility or alternate design possibilities for symbology.  You need to get the layer class, and depending on your type, you will want to do some casting.  If you know it is a point layer, for instance, you probably want to cast it into an IMapPointLayer interface, which is as precise as it needs to be to get a proper PointSymbolizer.  So it would be something like

IMapPointLayer mpl = map1.Layers[2] as IMapPointLayer;
if(mpl != null)
{
  mpl.Symbolizer.SetSize(new Size2D(10,10));
  mpl.Symbolizer.SetFillColor(Color.Red);     
}

The above code makes the assumption may apply the fill-color and size characteristic to multiple symbols if you make a composite symbol.  Each Symbolizer, for instance, can support multiple symbols, strokes or patterns, depending on if you are talking about points lines or polygons.  The default simple symbol supports a few default shape options, but you can also use CharacterSymbol in order to take advantage of scalable vector font glyphs like the ESRI font patterns, or you can use a PictureSymbol and load it with any image to your liking.

Ted

Jan 10, 2011 at 10:30 PM

As an added note, rather than grabbing the layer and casting it at that time, if you know you are going to be modifying a specific layer appropriately when the extents change, I would probably just keep the IMapPointLayer around as a private member variable so that you don't need to cycle through the layers and cast it each time.  That way there is less chance that something will go wrong from the order being changed or whatever.

Ted

 

Jan 11, 2011 at 10:29 AM

Thanks a lot Ted, your help is very appreciated!

Claus