If you use either the Authoritycode EPSG:3857 to create a projection, or the predefined KnownCoordinateSystems.Projected.World.WebMercator projection with OSM Mapnik, this projection is shifted about 100m Southwest.
Looking at the source code of the WebMap plugin in DotSpatial 1.6, i noticed that in many places the projection was converted to ToEsriString before passing it on to MapFrame, and this somehow solved the problem, a bit strange...
Finally I found in the ToEsriString() code a statement which adds a fix resetting the datum to WGS1984 so this is what did it. Now to get an accurate WebMercator projection you need to use this:
var projection = KnownCoordinateSystems.Projected.World.WebMercator;
projection.GeographicInfo.Datum = KnownCoordinateSystems.Geographic.World.WGS1984.GeographicInfo.Datum;
What bothers me most is that this appearantly cannot be achieved with any Proj4 format projection string I could find or tried to construct myself, even though this code was based on a port of proj4 at some point in time ;-)
more information:
https://trac.osgeo.org/gdal/ticket/3962
http://forums.esri.com/Thread.asp?c=93&f=984&t=288073
Sorry i do not have a Unit test ready to demonstrate this, but if you are having issues with WebMercator, i would recommend trying the above datum fix ?
Comments: ** Comment from web user: Marc_Olie **
Hello,
I had the same problem, and the reason why the transformation is not correct is that the datumtransform is never applied. The proj4 string for web mercator doesn't contain a datum element. Because of this the _datumtype for the datum is never set (it stays datumtype.unknown). In the datumtransform function there is a check:
```
/* -------------------------------------------------------------------- */
/* We cannot do any meaningful datum transformation if either */
/* the source or destination are of an unknown datum type */
/* (ie. only a +ellps declaration, no +datum). This is new */
/* behavior for PROJ 4.6.0. */
/* -------------------------------------------------------------------- */
if (sDatum.DatumType == DatumType.Unknown ||
dDatum.DatumType == DatumType.Unknown) return;
```
The datumType from WGS1984 is set, so by explicitly taking the datum from that definition, the above check will be passed and the datumshift is calculated.
Hope this helps solving this problem. I guess the easiest (but dirty) way would be to change the webmercator definition in the knowCoordinatesystems...
BTW I use the solution in my code and it works perfectly, so thanks!
Marc