How to draw a point on a VectorLayer backed with a shp file

Topics: General Topics, SharpMap Project, SharpMap v0.9 / v1.x, WinForms Controls
Nov 5, 2013 at 10:28 AM
Edited Nov 7, 2013 at 12:22 AM
I have a problem with adding a point with latitude and longitude on my sharpmap vectorlayer of China map.
Initially, My code is like following:
            SharpMap.Layers.VectorLayer layTarget = new SharpMap.Layers.VectorLayer("point");
            GeometryProvider geoProvider = new SharpMap.Data.Providers.GeometryProvider(new List<IGeometry>());
            layTarget.DataSource = geoProvider;
            layTarget.SRID = 4326;
            NetTopologySuite.Geometries.Point point = new NetTopologySuite.Geometries.Point(39.908, 116.397);
But I found the point added in the wrong position. And no matter what longitude and latitude I use, the point is fixed there below the map body on the screen.
Afterwards. I added the following code referencing the tutorial.
            ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctFact = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            ProjNet.CoordinateSystems.CoordinateSystemFactory csFact = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
            layTarget.CoordinateTransformation = (GeoAPI.CoordinateSystems.Transformations.ICoordinateTransformation)               ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, GetEPSG900913(csFact));
            layTarget.ReverseCoordinateTransformation = (GeoAPI.CoordinateSystems.Transformations.ICoordinateTransformation)
                ctFact.CreateFromCoordinateSystems(GetEPSG900913(csFact), ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84);
private IProjectedCoordinateSystem GetEPSG900913(ProjNet.CoordinateSystems.CoordinateSystemFactory csFact)
            List<GeoAPI.CoordinateSystems.ProjectionParameter> parameters = new List<ProjectionParameter>();
            parameters.Add(new ProjectionParameter("semi_major", 6378137.0));
            parameters.Add(new ProjectionParameter("semi_minor", 6378137.0));
            parameters.Add(new ProjectionParameter("latitude_of_origin", 0.0));
            parameters.Add(new ProjectionParameter("central_meridian", 0.0));
            parameters.Add(new ProjectionParameter("scale_factor", 1.0));
            parameters.Add(new ProjectionParameter("false_easting", 0.0));
            parameters.Add(new ProjectionParameter("false_northing", 0.0));
            IProjection projection = csFact.CreateProjection("Google Mercator", "mercator_1sp", parameters);
            IGeographicCoordinateSystem wgs84 = csFact.CreateGeographicCoordinateSystem(
                "WGS 84", ProjNet.CoordinateSystems.AngularUnit.Degrees, ProjNet.CoordinateSystems.HorizontalDatum.WGS84, ProjNet.CoordinateSystems.PrimeMeridian.Greenwich,
                new AxisInfo("north", AxisOrientationEnum.North), new AxisInfo("east", AxisOrientationEnum.East)

            IProjectedCoordinateSystem epsg900913 = csFact.CreateProjectedCoordinateSystem("Google Mercator", wgs84, projection, ProjNet.CoordinateSystems.LinearUnit.Metre,
              new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
            return epsg900913;
But I found the point completely dispeared

Please help me out of this problems. Thanks.
Nov 6, 2013 at 11:53 PM
Does anyone give a hand? I am a newbies on GIS and Sharpmap, and please seniors can help me out .
Nov 7, 2013 at 5:58 AM
What is "china map"?
You need to set up a coordinate transformation to that of your other map components.
Nov 9, 2013 at 7:06 AM
Thanks, FObermaier.
The "China map" means a map of China. I know I need a coordinate transformation ,and I tried to do that in the above code. Can anyone figure out what's wrong with my code? and Is there any example code I can refer to ? Thanks
Nov 9, 2013 at 7:57 AM
No I can't as I have no knowledge about what your "china map" is. Is it a vector layer, a tile service, a raster?
Then I need to know what the spatial reference system is.

If you know that all you have to do is look up the Well-Known-Text representation of it. Then I can help you.