Moving marker on the map

Topics: SharpMap v0.9 / v1.x, SharpMap v2.0
Oct 26, 2012 at 9:58 AM

Hi,

I created a simple map in WPF, that use a locale tile cache

FileTileProvider(new FileCache(GetAppDir() + "\\GMapLocalCache", "png"));

this map is work fine.
I draw few PointLayer with PointLayerWithWorldUnitsForSymbolsSample
    public static class PointLayerWithWorldUnitsForSymbolsSample
    {
        public static ILayer Create()
        {
            var layer = new Layer("PointLayer WorldUnits");
            var netherlands = new Feature { Geometry = new Point(710000, 6800000) };

            const string resource = "MapsUI_Proba1.Image.lightuv.png";

            netherlands.Styles.Add(new SymbolStyle
            {
                Symbol = new Bitmap
                {
                    Data = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)
                },
                SymbolType = SymbolType.Rectangle,
                UnitType = UnitType.WorldUnit,
                SymbolRotation = 5f,
                SymbolScale = 1400,
                Width = 365,
                Height = 380
            });

            layer.DataSource = new MemoryProvider(new[] { netherlands });
            return layer;
        }
    }
My 2 questions:
How can move these layer to another position (without redraw map)
How to fixing the size of marker, and shows on every zoom level (with same size)

 Please paste a little code snippet. Thanks!

Developer
Nov 2, 2012 at 5:43 AM
How to fixing the size of marker, and shows on every zoom level (with same size)

--> Set SymbolScale = 1,

How can move these layer to another position (without redraw map)

In core of sharpmap, we have to get a image of all layers. You can not refresh only one layer of map at the present. You can use FeatureDataTable in order to save this layer on memory and add to repaint event of mapbox on form. Example:

private void Mappanel_Paint(object sender, PaintEventArgs e)
        {
            
            // reraw Feature dataset
            if (Global.myMap.DataSetSelected.Tables.Count > 0)
            {
                DataTable fDT = Global.myMap.DataSetSelected.Tables[0];
                for (int i = 0; i < fDT.Rows.Count; i++)
                {
                    FeatureDataRow row = fDT.Rows[i] as SharpMap.Data.FeatureDataRow;
                    switch (row.Geometry.GetType().FullName)
                    {
                        case "SharpMap.Geometries.Point":                           
                          
                            Bitmap bitMap = SharpMap.Rendering.VectorRenderer.endsymbol;                            
                            SharpMap.Rendering.VectorRenderer.DrawPoint(e.Graphics, row.Geometry as SharpMap.Geometries.Point, bitMap, 1, new PointF(0, 0), 0, Global.myMap.Map);
                            break;
                        case "SharpMap.Geometries.MultiPoint":
                            break;
                        case "SharpMap.Geometries.LineString":
                            SharpMap.Rendering.VectorRenderer.DrawLineString(e.Graphics, row.Geometry as SharpMap.Geometries.LineString, Global.SelectedPen, Global.myMap.Map);
                            break;
                        case "SharpMap.Geometries.MultiLineString":
                            SharpMap.Rendering.VectorRenderer.DrawMultiLineString(e.Graphics, row.Geometry as SharpMap.Geometries.MultiLineString, Global.SelectedPen, Global.myMap.Map);
                            break;
                        case "SharpMap.Geometries.Polygon":
                            SharpMap.Rendering.VectorRenderer.DrawPolygon(e.Graphics, row.Geometry as SharpMap.Geometries.Polygon, Global.SelectedColorBrush, Global.SelectedPen, false, Global.myMap.Map);
                            break;
                        case "SharpMap.Geometries.MultiPolygon":
                            SharpMap.Rendering.VectorRenderer.DrawMultiPolygon(e.Graphics, row.Geometry as SharpMap.Geometries.MultiPolygon, Global.SelectedColorBrush, Global.SelectedPen, false, Global.myMap.Map);
                            break;
                        default:
                            break;
                    }
                }
            }
                     
        }