The map doesn't refresh after drawing a line onmousemove() event

Jun 12, 2009 at 2:23 PM

Hi everybody,

I want to draw a poly line. I declared 2 layers, one for drawing a poly line, the other is temp layer which draw a line on mousemove() event.
Here is my code

        //Layer draw polyline onmouseclick()
        private SharpMap.Layers.VectorLayer VlayerConnection;
        private System.Collections.ObjectModel.Collection<SharpMap.Geometries.Point> PointConnection;
        private System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry> GeometryConnection;
        private string LayerNameConnection = "LayerConnection";

        //Layer draw a temp line onmousemove()
        private SharpMap.Layers.VectorLayer VlayerTmp;
        private System.Collections.ObjectModel.Collection<SharpMap.Geometries.Point> PointTmp;
        private System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry> GeometryTmp;
        private string LayerNameTmp = "LayerTmp";

        SharpMap.Geometries.Point CurrentPoint = new SharpMap.Geometries.Point();

        private void mapControl1_MouseUp(object sender, SharpMap.Presentation.Windows.MouseButtonEventArgs e)
        {
            DrawOnMouseClick(e.WorldPos);
        }

        private void DrawOnMouseClick(SharpMap.Geometries.Point p)
        {
            if (!flagDraw) return;
            PointConnection.Add(p);
            CurrentPoint = p;
            this.mapControl1.BeginUpdateMap();
        }

        private void mapControl1_MouseMove(object sender, SharpMap.Presentation.Windows.MouseEventArgs e)
        {
            DrawOnMouseMove(e.WorldPos);
        }

        private void DrawOnMouseMove(SharpMap.Geometries.Point p)
        {
            if (!flagDraw) return;
            if (PointConnection.Count > 0 && IsAnotherPoint(CurrentPoint, p))
            {
                PointTmp.Clear();
                GeometryTmp.Clear();

                PointTmp.Add(PointConnection[PointConnection.Count - 1]);
                PointTmp.Add(p);

                GeometryTmp.Add(new SharpMap.Geometries.LineString(PointTmp));
                this.mapControl1.BeginUpdateMap();

                CurrentPoint = p;
            }
        }

 

I used BeginUpdateMap() method to refresh map after drawing a temp line when mouse move. But the map refresh slowly sometimes the map doesn't refresh. If I zoom in or zoom out the map, the temporary line displayed immediately.
 
Can you help me?

Jun 14, 2009 at 3:27 AM

Pls help me !

Thanks for any feedback.

Jun 17, 2009 at 9:23 AM
<abbr />
<input id="ctl00_ctl00_MasterContent_Content_PostRepeater_ctl02_PostId" name="ctl00$ctl00$MasterContent$Content$PostRepeater$ctl02$PostId" type="hidden" value="201240" />

Pls help me !

Thanks for any feedback.

Coordinator
Jun 18, 2009 at 10:29 AM

Hi nguyen1phuong, which version of sharpmap are you using? I suspect a very old one as MapControl no longer exists in the source - it has been replaced with MapImage. If you can download the latest source from the Source Code tab http://sharpmap.codeplex.com/SourceControl/ListDownloadableCommits.aspx and build the solution in the Trunk directory, you can then modify your app to use the newly built dlls and see if you have the same / similar issues

hth jd

Jun 30, 2009 at 12:12 PM

See some usefull links in this page

 

http://www.solutionwindow.com/sharpmap/default.asp

 

Regards,

AH

Jul 1, 2009 at 4:49 AM

Thanks for your reply, johndiss. I will update my sharpmap version and hope it runs well