Here is the code from the sample application. I have just changed the accaountId, password, IpAddress. Further I have added LoadVirtualEarthLayer() in UseMicrosoftMapsLayer_load().
private void LoadVirtualEarthLayer() { // Please set your own information about those parameters below. string accountId = "xxxxxx"; string password = "xxxxxxx"; string clientIpAddress = "10.1.xx.xx"; string cacheDirectory = @"c:\temp\";
VirtualEarthLayer worldLayer = new VirtualEarthLayer(accountId, password, clientIpAddress, cacheDirectory);
LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("WorldLayer", worldLayer); winformsMap1.Overlays.Add(staticOverlay);
winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); winformsMap1.CurrentExtent = new RectangleShape(-143.4, 109.3, 116.7, -76.3);
I think that's because Virtual Earth's ZoomLevelSet is different from the default one. Please add the one line code "winformsMap1.ZoomLevelSet = new GoogleMapZoomLevelSet();" before "winformsMap1.Refresh();" and have another try. If you still have problem, please change the winformsMap1.MapUnit to MapUnit.Meter, and change winformsMap1.CurrentExtent to "new RectangleShape(-10000000, 10000000, 10000000, -10000000);" and have a try. The VirtualEarthLayer should only support the MapUnit.Meter, but not MapUnit.DecimalDegree. (The HowDoI sample is not using the right unit) Let us know what you find out.
After many iterations I found a work-around. See the source code shown below. The main trick is the call of ZoomToScale.
Please update your "How Do I" test application :-)
And now the final question: Do you know which coordinate system VirtualEarthLayer is using ?
Best regards
Niels Olsen
// Please set your own information about those parameters below. string accountId = "xxxxx"; string password = "xxxxxx"; string clientIpAddress = "10.1.xx.xx"; string cacheDirectory = @"c:\temp\";
VirtualEarthLayer worldLayer = new VirtualEarthLayer(accountId, password, clientIpAddress, cacheDirectory);
LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("WorldLayer", worldLayer); winformsMap1.Overlays.Add(staticOverlay);
winformsMap1.MapUnit = GeographyUnit.Meter; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); winformsMap1.CurrentExtent = new RectangleShape(-10000000, 10000000, 10000000, -10000000);
Thanks for your kindly help:), we have corrected the HowDoI samples.
The coorindate system used in VitrualEarthLayer is Mecator, its projection string should be +proj=merc+a=6378137+b=6378137+lat_ts=0.0+lon_0=0.0+x_0=0.0+y_0=0+k=1.0+units=m+no_defs