I've just started using Sharpmap but I have a problem. I'm not able to print points (not even one) over a map using this library.
I didn't find a good example to do it, and my code is not working. It draws a point way too far from where it should be (Madrid, Spain).
I would appreciate some help if someone knows how to use it.
Here is my code :
namespace TestsSharpmapForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
VectorLayer vlay = new VectorLayer("Spain");
vlay.DataSource = new SharpMap.Data.Providers.ShapeFile(@"ESP_adm_shp\ESP_adm2.shp", true);
VectorLayer vlay2 = new VectorLayer("Points");
Collection<GeoAPI.Geometries.IGeometry> geomColl = new Collection<GeoAPI.Geometries.IGeometry>();
//Get the default geometry factory
GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();
GeoAPI.Geometries.IGeometryFactory gf =
GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory();
geomColl.Add(gf.CreatePoint(new GeoAPI.Geometries.Coordinate(40.4177623, -3.6690416)));
vlay2.DataSource = new SharpMap.Data.Providers.GeometryProvider(geomColl);
mapBox1.Map.Layers.Add(vlay);
mapBox1.Map.Layers.Add(vlay2);
//ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctFact = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
//vlay.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84, ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
//vlay.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator, ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84);
mapBox1.Map.ZoomToExtents();
mapBox1.Refresh();
mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;
Image imgMap = mapBox1.Map.GetMap();
}
private void mapBox1_Click(object sender, EventArgs e)
{
}
}
}
X and Y should be the other way round: