ThinkGeo.com    |     Documentation    |     Premium Support

Switching between Bing Map and World Map Kit Online

We have licenses for both services.
How can I switch dynamically?
I have 2 buttons on my form and I can see Bing Map (default), but when I click to show World Map it shows empty window.

BingMapsOverlay _bingOverlay = new BingMapsOverlay(“xxxxxxxxxxxx”);

WorldMapKitWmsDesktopOverlay _worldMapKitOverlay = new WorldMapKitWmsDesktopOverlay(@“xxxxx”, @“xxxxxxxxxxxxx”);

    private void buttonShowBingOverlay_Click(object sender, EventArgs e)
    {
        mapEngine.Overlays.Remove(_worldMapKitOverlay);
        _bingOverlay.MapType = BingMapsMapType.AerialWithLabels;
        mapEngine.Overlays.Add(_bingOverlay);
        mapEngine.Refresh();
    }

    private void buttonShowThinkGeoOverlay_Click(object sender, EventArgs e)
    {
        mapEngine.Overlays.Remove(_bingOverlay);
        _worldMapKitOverlay.MapType = WorldMapKitMapType.AerialWithLabels;
        mapEngine.Overlays.Add(_worldMapKitOverlay);
        mapEngine.Refresh();
    }

Hi Alex,

I guess this issue may be caused by the projection, the projection of WorldMapKitWmsDesktopOverlay is DecimalDegree, but BingMapsOverlay is Meter. There are 2 options for that.

  1. Set the Projection property of WorldMapKitWmsDesktopOverlay to WorldMapKitProjection.SphericalMercator(recommend this one).

  2. Projection the BingMapsOverlay to DecimalDegress by setting ProjectionFromSphericalMercator property.

Thanks,
Peter

Hello Peter,
The option 1 works fine (except I noticed right away than WorldMapKit Online with Aerial works much more slower than Bing with Aerial maps);

But I would prefer to work with Decimal Degrees, so I would like to implement option 2.
When I tried that I’m getting error message:
An unhandled exception of type ‘System.AccessViolationException’ occurred in MapSuiteCore.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Here is my form load method:

mapEngine.MapUnit = GeographyUnit.DecimalDegree;
mapEngine.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetBingMapParametersString();
proj4.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();

_bingOverlay.ProjectionFromSphericalMercator = proj4;
mapEngine.Overlays.Add(_bingOverlay);

mapEngine.Refresh();


This code is based from this discussion about Google re-projection:

Thank you,
Alex.

Hi Alex,

We had done enhancements for the “Map Suite Unmanaged Dependencies” since version 9.0.295.0, I guess the issue you encounter is related to this. Please download the “Map Suite Unmanaged Dependencies 9.0.295.0” and upgrade the “Map Suite Unmanaged Dependencies” to have a try again.

Thanks,
Peter

Thanks, Peter! Everything works now after the upgrade!

Sincerely,
Alex,

Hi Alex,

I am glad to hear that works.

Regards,

Don