draw polygon

Topics: Web Controls
Mar 4, 2008 at 4:56 AM
Hi
I want to draw polygon on web page using sharpmap.But I can not draw.Though I can draw line by the help of " Add a primitive geometry" from this site .That's why I am waiting for the help .
Can any body help me ?
My code of drawline is here



SharpMap.Layers.VectorLayer layertest = new SharpMap.Layers.VectorLayer("test");
System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry> GeomColl = new System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry>();
System.Collections.ObjectModel.Collection<SharpMap.Geometries.Point> pointCall = new System.Collections.ObjectModel.Collection<SharpMap.Geometries.Point>();

double a, b, e, f, g, h, p, q, s, t;
a = 90.1146541372;
b = 23.9457483088;
e = 89.114654372;
f = 23.9457483088;
pointCall.Add(new SharpMap.Geometries.Point(a, b));
pointCall.Add(new SharpMap.Geometries.Point(e, f));
layertest.Style.Line = new Pen(Color.Red, 2);
layertest.Style.Line.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
layertest.Style.Line.EndCap = System.Drawing.Drawing2D.LineCap.Round;
GeomColl.Add(new SharpMap.Geometries.LineString(pointCall));
layertest.DataSource = new SharpMap.Data.Providers.GeometryProvider(GeomColl);
myMap.Layers.Add(layertest);
Developer
Mar 4, 2008 at 2:35 PM
Edited Mar 4, 2008 at 2:42 PM
When I put your code in a method and call it the constructor of DemoWinForm and press 'zoom to extents' directly after startup, I see a horizontal red line. See code below.

Is your drawing layer on top of the others? Do you use the correct Map object? Did you zoom to extents?


public MainForm()
{
InitializeComponent();
registerSymbols();
registerKnownColors(_colorTable);
registerLayerFactories();
MainMapImage.MapQueried += new MapImage.MapQueryHandler(MainMapImage_MapQueried);

Test();
}

private void Test()
{
SharpMap.Layers.VectorLayer layertest = new SharpMap.Layers.VectorLayer("test");
System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry> GeomColl = new
System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry>();
System.Collections.ObjectModel.Collection<SharpMap.Geometries.Point> pointCall = new
System.Collections.ObjectModel.Collection<SharpMap.Geometries.Point>();

double a, b, e, f, g, h, p, q, s, t;
a = 90.1146541372;
b = 23.9457483088;
e = 89.114654372;
f = 23.9457483088;
pointCall.Add(new SharpMap.Geometries.Point(a, b));
pointCall.Add(new SharpMap.Geometries.Point(e, f));
layertest.Style.Line = new Pen(Color.Red, 2);
layertest.Style.Line.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
layertest.Style.Line.EndCap = System.Drawing.Drawing2D.LineCap.Round;
GeomColl.Add(new SharpMap.Geometries.LineString(pointCall));
layertest.DataSource = new SharpMap.Data.Providers.GeometryProvider(GeomColl);
this.MainMapImage.Map.Layers.Add(layertest);
}
Mar 12, 2008 at 6:55 AM
Hi pauldendulk

Yes this layer is top of other layer and I use zoom to extents method.
thanks for reply

Is there any way to identify the polygon of a shap flie by click on it ???
Or if it is not possible please notify me.
Coordinator
Mar 13, 2008 at 4:59 PM
Hi neoo -

In v0.9/v1.0, you need to do an intersection test on your feature layers yourself to select features.

In v2.0, it's built into SharpMap.
Mar 16, 2008 at 4:48 PM
thank you codekaizen for your answer.

sorry .The solution you say it is not clear to me.

I am using v0.9 . Do u have any example code in source code to identify a polygon in a shape file by click ?
If ajax map control support this feature also give me some example.

Again thank you.