AjaxMap + NTS - Add a layer at runtime -- noone replied

Topics: SharpMap Project, SharpMap v0.9 / v1.x, Web Controls
Jul 1, 2008 at 8:14 AM
Edited Jul 1, 2008 at 8:22 AM
Hello,
I have used the Oid of Clicked Point post to show a map of an area with plots marked out.
When a user clicks on a plot, information about the plot is fetched and displayed in a grid.
At the same time, I wanted to color the plot on which the user has clicked. For this I am trying to add a new layer using the following code:

....

SharpMap.Geometries.

Point ClickPnt = new SharpMap.Geometries.Point(pntx, pnty);

 

SharpMap.Data.

 

FeatureDataSet ds = new SharpMap.Data.FeatureDataSet();
SharpMap.Geometries.BoundingBox bx = ClickPnt.GetBoundingBox();
(ajaxMap.Map.Layers[0]
as SharpMap.Layers.VectorLayer).DataSource.ExecuteIntersectionQuery(bx, ds);
...

 

SharpMap.Layers.

VectorLayer laySelected = new SharpMap.Layers.VectorLayer("Selection");
laySelected.DataSource =
new GeometryProvider(ds.Tables[0]);
laySelected.Style.Fill =
new System.Drawing.SolidBrush(System.Drawing.Color.Yellow);
laySelected.Enabled =
true;
laySelected.Style.Enabled =
true;
ajaxMap.Map = MapHelper.AddLayer(ajaxMap.Map, laySelected);
ajaxMap.Map.Zoom = curzoom;
ajaxMap.Map.Center.X = pntx;
ajaxMap.Map.Center.Y = pnty;

 

 

 

And I am using 

ajaxMap.ResponseFormat = "maphandler.ashx?MAP=SimpleWorld&Width=[WIDTH]&Height=[HEIGHT]&Zoom=[ZOOM]&X=[X]&Y=[Y]";

to refresh the Map. Here the implementation of AddLayer is as follows:

 public static SharpMap.Map AddLayer( SharpMap.Map thisMap, SharpMap.Layers.VectorLayer newLayer)
{
    thisMap.Layers.Add(newLayer);
    HttpContext.Current.Trace.Write("Layer Added");
    return map;
}

 

 

 

</FONT>

 

 

But the plot is not getting colored.

Could you please help me???

Thanks in Advance

 

 

Jul 3, 2008 at 10:48 AM
Hello All,

Further to all my posts in Highlight selected feature for the same problem, I have typecasted the relevant variables and now my project is compiling. However, I am now getting the following run-time error:

System.MissingMethodException: Method not found: 'Void SharpMap.Map.set_HasLegd(Boolean)'

Which means the NetTopology and GeoApi are anyway not compatible.

Have anybody else managed to achieve this?

Regards,
Jul 3, 2008 at 11:34 AM
Hello

Sorry for repeated posts:

I managed to get the code working with an earlier dll.

However, my polygon is still not getting highlighted.

Here is the code:

SharpMap.Layers.

VectorLayer layToQuery = ajaxMap.Map.Layers[1] as SharpMap.Layers.VectorLayer;

 

SharpMap.Data.

FeatureDataRow rowSelected = MapHelper.FindGeoNearPoint(pointClick, layToQuery, 30);

 

SharpMap.Layers.

VectorLayer laySelected = new SharpMap.Layers.VectorLayer("Selection");

 

laySelected.DataSource =

new SharpMap.Data.Providers.GeometryProvider(rowSelected.Geometry);

 

laySelected.Style.Fill =

new System.Drawing.SolidBrush(System.Drawing.Color.Yellow);

 

laySelected.Enabled =

true;

 

laySelected.Style.Enabled =

true;

 

 

//ajaxMap.Map.Layers.Add(laySelected);

 

ajaxMap.Map =

MapHelper.AddLayer(ajaxMap.Map, laySelected);

 

ajaxMap.Map.Zoom = curzoom;

ajaxMap.Map.Center.X = pntx;

ajaxMap.Map.Center.Y = pnty;

 

ajaxMap.ResponseFormat =

"maphandler.ashx?MAP=SimpleWorld&Width=[WIDTH]&Height=[HEIGHT]&Zoom=[ZOOM]&X=[X]&Y=[Y]";

 

 

//String abc = "Iamaham";

 



Any ideas?
Jul 7, 2008 at 12:51 PM
I can attach the entire code if anyone is interested. Please help.

I tried to display an icon at the clicked point, again by adding a layer. Doesnt seem to work..

:(
Aug 1, 2009 at 3:39 AM

Hi  Pinging! Have you solved this problem? I also meet  this question  in Ajax demo. When i plot a  symbol  at clicked point and add it as a layer, it does not  work!  Can you help me ? Thanks