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

How to plot marker on sharp map ?

Topics: SharpMap Project
May 31, 2013 at 6:15 AM
I have taken an image and attached country shape files to it. It's working fine.
Now I want to plot marker for places on map, can any body help me out with code, how it can be done ?
May 31, 2013 at 8:51 AM
Have a look at the WinFormSamples project. there is an example of using OpenStreetMap basemap a set or point markers.
May 31, 2013 at 10:50 AM
Hi FOermaier,
Thanks for your reply.
I m not able to find the code.
Do I need Shape files for plotting the markers as well ?Can you give me the code snippets ?
May 31, 2013 at 1:41 PM
This should get you started. Will need refactoring to fit your needs

public void AddPoint(SharpMap.Map myMap)
    SharpMap.Layers.VectorLayer vectorLayer = new VectorLayer("GeometryLayer");

    Collection<GeoAPI.Geometries.IGeometry> geomColl = new Collection<GeoAPI.Geometries.IGeometry>();

    //Get the default geometry factory

    GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();
    var gf = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory();

    myPoint = gf.CreatePoint(new Coordinate(-1, 52));


    System.Drawing.Image bitmapCity = Image.FromFile("C:\\cctv_camera.png");  // Mapper.Properties.Resources.city_pin;

    var MyStyle = new SharpMap.Styles.VectorStyle();

    MyStyle.Symbol = new Bitmap(bitmapCity);

    vectorLayer.Style = MyStyle;

    vectorLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(geomColl);


Jun 4, 2013 at 7:53 AM
Hi Robert_Smart,
Thanks for the code.
I downloaded GeoAPI dll but when I try to add in my application, it gives me error---
"Could not load file or assembly 'SharpMap.Web' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. "
Can you help me out ?
Jun 4, 2013 at 9:55 AM
You need to target Full .Net Framework 4.0 when using SharpMap.Web.
Hth FObermaier
Jun 4, 2013 at 1:11 PM
Thanks FObermaier and Robert_Smart,
I targeted the project on 4.0 framework. Now only one question is remaining is about data source binding.
I have binded Shape files like
//Set up a road layer
        SharpMap.Layers.VectorLayer layRivers = new SharpMap.Layers.VectorLayer("Roads");
        //Set the datasource to a shapefile in the App_data folder
        layRivers.DataSource = new SharpMap.Providers.ShapeFile(Server.MapPath(@"~\App_data\roads.shp"), true);
        //Define a blue 1px wide pen
        layRivers.Style.Line = new Pen(Color.Blue,1);
How I can bind the marker to the shape file?
Please let me know ..
Jun 4, 2013 at 1:49 PM
what do you mean? It looks like your loading a line shapefile?

You would normally use a point shapefile for showing markers.
Jun 4, 2013 at 1:51 PM
Edited Jun 4, 2013 at 1:53 PM
Yes... I binded Road Shape files like that..this is what i wanted to explain.
Now, the question is how I can bind a Point of Interest/ Marker on map ?
I am not getting reference to SharpMap.Data namespace ?Which dll should I refer for tat ?