static CoordinateConverter() { CoordinateTransformationFactory ctFactory = new CoordinateTransformationFactory(); LonLatToWebTransform = ctFactory.CreateFromCoordinateSystems(WGS84, WebMercator).MathTransform; WebToLonLatTransform = LonLatToWebTransform.Inverse(); }
public static double[] ConvertLatLonToWebMercator(LatitudeLongitude latLon) { try { double[] lonLatPoint = { latLon.Longitude, latLon.Latitude }; return(LonLatToWebTransform.Transform(lonLatPoint)); } catch (Exception ex) { return(new double[] { double.NaN, double.NaN }); } }