Can't add geometry on Map

Topics: SharpMap Project, SharpMap v2.0, WinForms Controls
Oct 16, 2007 at 4:34 AM
I want to create a line over a map which I load from Shapefile as one layer and it work well with latitude and longitude display on mouse move.

I try to add a line over that map by create new layer but it doesn't work

SharpMap.Layers.VectorLayer VLayer = new VectorLayer("GeometryLayer");


Collection<SharpMap.Geometries.Geometry> GeomColl = new Collection<SharpMap.Geometries.Geometry>();
//Add a single Point
GeomColl.Add(new SharpMap.Geometries.Point(10, 10));

//Add a LineString with 2 Points
Collection<SharpMap.Geometries.Point> PointColl = new Collection<SharpMap.Geometries.Point>();
PointColl.Add(new SharpMap.Geometries.Point(10, 10));
PointColl.Add(new SharpMap.Geometries.Point(20, 20));

ERROR ->GeomColl.Add(new SharpMap.Geometries.LineString(PointColl));
ERROR ->VLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(GeomColl);

map.Layers.Add(VLayer);


Error list :

Error 1 The best overloaded method match for 'SharpMap.Geometries.LineString.LineString(System.Collections.Generic.List<SharpMap.Geometries.Point>)' has some invalid arguments

Error 2 Argument '1': cannot convert from 'System.Collections.ObjectModel.Collection<SharpMap.Geometries.Point>' to 'System.Collections.Generic.List<SharpMap.Geometries.Point>'

Error 3 The best overloaded method match for 'SharpMap.Data.Providers.GeometryProvider.GeometryProvider(System.Collections.Generic.List<SharpMap.Geometries.Geometry>)' has some invalid arguments

Error 4 Argument '1': cannot convert from 'System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry>' to 'System.Collections.Generic.List<SharpMap.Geometries.Geometry>'



How can I fix and could you please show me a complete example for desktop application ?

Thanks in Advance

Mickey00

Coordinator
Oct 16, 2007 at 5:20 AM
Which version are you using?
Oct 16, 2007 at 6:08 AM
Version 0.9.0.0
Oct 16, 2007 at 6:41 AM
Consider using List<Point> as input instead of Collection<Point> as the compiler tells you:

Error 1 The best overloaded method match for 'LineString(List<Point>)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'Collection<Point>' to 'List<Point>'
Oct 17, 2007 at 3:41 AM
Thank you. Problem Solved !