TileAsyncLayer Incorrect Coordinates

Topics: General Topics, SharpMap v0.9 / v1.x
Jan 13, 2015 at 2:27 AM
Edited Jan 13, 2015 at 2:28 AM
Hello,

I am new to SharpMap and I am simply adding a new BingMaps layer to a blank map and displaying the coordinates to a Winforms label. However, the coordinates returned are extremely large (sample output: [Coordinates: -7317306.65596541 19441913.6149779])! Not sure what I'm missing here.
    public partial class MySharpMap : SharpMap.Forms.MapBox
    {
        public MySharpMap() : base() { }
        
        public void InitializeBingMapBackgroundLayer()
        {
            var layer = new SharpMap.Layers.TileLayer(new BruTile.Web.BingTileSource(BruTile.Web.BingRequest.UrlBingStaging, "", BruTile.Web.BingMapType.Hybrid), "TileLayer - Bing Aerial");
            this.Map.Layers.Add(layer);
        }
    }
Calling from here:
namespace SharpMapTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            mySharpMap.InitializeBingMapBackgroundLayer();
            mySharpMap.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;
        }

        private void mySharpMap_MouseMove(GeoAPI.Geometries.Coordinate worldPos, MouseEventArgs imagePos)
        {
            label1.Text = "Coordinates: " + worldPos.X + " " + worldPos.Y;
        }
    }
}
Coordinator
Jan 13, 2015 at 12:01 PM
The coordinates you are getting are in WebMercator (EPSG:3857) and not WGS84 (EPSG:4326).
Jan 13, 2015 at 5:41 PM
How can I change the map transform to return WGS84 coordinates instead of WebMercator in the MouseMove handler?

I've tried the following to no avail.
        public void InitializeBingMapBackgroundLayer()
        {
            var layer = new SharpMap.Layers.TileLayer(new BruTile.Web.BingTileSource(BruTile.Web.BingRequest.UrlBingStaging, "", BruTile.Web.BingMapType.Hybrid), "TileLayer - Bing Aerial");
            layer.CoordinateTransformation = GoogleToWgs84();
            layer.ReverseCoordinateTransformation = Wgs84ToGoogle();
            this.Map.Layers.Add(layer);
        }

        public static ICoordinateTransformation Wgs84ToGoogle()
        {
            var cfact = new CoordinateTransformationFactory();
            return cfact.CreateFromCoordinateSystems(GeographicCoordinateSystem.WGS84, ProjectedCoordinateSystem.WebMercator);
        }

        public static ICoordinateTransformation GoogleToWgs84()
        {
            var cfact = new CoordinateTransformationFactory();
            return cfact.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WebMercator, GeographicCoordinateSystem.WGS84);
        }
Coordinator
Jan 14, 2015 at 11:50 AM
you need to use the coordinate transformation WebMercator -> WGS84 in the MouseMove event.
Setting the (Reverse)CoordinateTransformation does not have any effect on TileLayers.