This project has moved and is read-only. For the latest updates, please go here.

Add a primitive geometry with Ajax Control

Topics: SharpMap Project, SharpMap v0.9 / v1.x, Web Controls
Dec 3, 2008 at 3:13 AM

I have been trying to add few point data on the map using the sample code provided in this link
A new layer is added to the map, and i have all the points that i have added in that layer. But the issues is that im not able to view them on the map.
I have tried two method and i would like to know what is the exact difference in the method. As im want the method 2 be working going ahead i would request help in resolving the issues.

Method 1:
    In the map initialize method i add the point layer that i wanted to show on the map. Similar to how we add the shapefile's are been added at the start.
    The point layer was added to the map and i was able to view the point data on the map.
    The code for added the point data as a layer is same in both the case

Method 2: (Current approach)
    Using a button click, i call a function to all the point data on the map.
    Layer gets added with all the points in them.
    Issues not able to view the point data on the map

Sample code (Same for both the method)
        SharpMap.Layers.VectorLayer player = new SharpMap.Layers.VectorLayer("myPointLayer");
List<SharpMap.Geometries.Geometry> pList = new System.Collections.Generic.List<SharpMap.Geometries.Geometry>();
new SharpMap.Geometries.Point(10, 5));
new SharpMap.Geometries.Point(14, 5));
new SharpMap.Geometries.Point(12, 12));
        player.DataSource = new SharpMap.Data.Providers.GeometryProvider(pList);
        player.Style.Fill =
new SolidBrush(Color.Red);
        player.Style.Outline = System.Drawing.
        player.Style.EnableOutline =
        player.Style.SymbolScale = 0.5f;
        player.Style.Enabled =
        player.SRID = 4326;
        //Zoom to the Current Layer Extend
        ajaxMap.Map.ZoomToBox(ajaxMap.Map.Layers[ajaxMap.Map.Layers.Count - 1].Envelope);


Dec 3, 2008 at 9:48 AM
Edited Dec 3, 2008 at 10:12 AM
You havent set the player.Style.Symbol property - it should be set to the bitmap that you want to represent a point. hth jd
Dec 3, 2008 at 10:16 AM
As mentioned by you i have used that also, please find the code below.

player.Style.Symbol =
new Bitmap(HttpContext.Current.Server.MapPath(@"~\App_data\pin30_green_h1.bmp"));

I have place the code just before adding the layer to map, but still im not able to view the point.
Do you think i shld apply the project to this layer, or im i missing something else


Dec 3, 2008 at 10:30 AM
Do you have other layers in a different projection? If so, try adding only the point layer to the map and see what you get..
Dec 4, 2008 at 1:42 AM
All the layers other than the point layer are in the same projection. For the point layer which we are adding, projection is not defined.
John when i add the same layer at the Map initialize, i mean add the layer on the map load the point layer is visible.
Currently im adding the point layer at the button click thats when im not able to view any points but the layer is found in the layer collection.

Do you think i shld share the proj with you, so that you can cross check and possible suggest the fixes as well.
Dec 4, 2008 at 10:46 AM
If the layers are in different coordinate systems then one or more layers must be reprojected so that they all end up in the same coordinate system.
If all the data for all layers are in the same coordinate system, but one or more layers have a Transform applied, then either you need to: remove all the transforms or add it to all layers.. hth jd
Aug 1, 2009 at 8:17 AM

hi,arunachalamt! Have you solved the problem as you mentioned ?  I  also met the same  trouble ! Can you help me?