ThinkGeo.com    |     Documentation    |     Premium Support

BaseMap : Bing, Google, MapBox, etc

Hi,

I have severall questions about the integration of google, bing, openstreetmap, mapbox in a wpf application.

  1. In our appplication, I used a BingMapslayer. When I enter the applicationId, I visualize the BaseMap bing.
    If I make a mistake typing in ApplicationId, to see what is the visual … I have an error not caught ;-(
    I have however specified the following code:

var layer = new BingMapsLayer(string.Empty, BingMapsMapType.Aerial)
{
DrawingExceptionMode = DrawingExceptionMode.DrawException
};
layer.DrawingException += Layer_DrawingException;
layer.DrawnException += Layer_DrawnException;

The error is this (this error is logic because i don’t have the applicationId
but I would want intercept the error ((as you do in your example BackgroundMapSwitchingSample-ForWpf-master example))

2018-11-07 11:13:08.8809 12:System.Net.WebException:Le serveur distant a retourné une erreur : (401) Non autorisé.
à ThinkGeo.MapSuite.Wpf.Tile.DrawException(GeoCanvas geoCanvas, Exception exception)
à ThinkGeo.MapSuite.Wpf.Tile.Draw(GeoCanvas geoCanvas)
à ThinkGeo.MapSuite.Wpf.Tile.hFY=(Object status)
à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
à System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
à System.Threading.ThreadPoolWorkQueue.Dispatch()

  1. Our application is in Lambert93 projection and the thinkgeo version used 10.2.5
    I looked at your BackgroundMapSwitchingSample-ForWpf-master example.
    This is an improvement that we want to make in order to offer the user to be able to switch from a basemap bing, google, mapbox, classic raster. (tif, ecw etc …)
    In your example, you use BingMapsTileOverlay and not BingMapsOverlay … what’s the difference?
    Currently, I’m using BingMapLayer, what’s the difference between BingMapLayer, BingMapsOverlay and BingMapsTileOverlay?
    When I look at the description of BingMapsOverlay, there is the notion of ProjectedTileCache and ProjectionFromSphericalMercator …
    Is it possible to reproject on the fly the tiles obtained from bing? ie reproject the EPSG tiles: 3857 to EPSG: 2154?
    Or is it better to keep the basemap bing in 3857 and reproject the vector layers that are in lambert93 to EPSG: 3857?
    For google, currently there is GoogleMapsLayer and GoogleMapsOverlay … what is the difference in terms of performance, etc …?
    In your example, you instantiate the layers you want to use and you play on the visibility of the layers to switch.
    What is the best approach in terms of performance, instantiate all layers and change the visibility of layers or instantiate the layer only when the user chooses the layer he wants to see?

Thanks a lot for your help.
Regards

Steph.

Hi Steph,

It looks you have 5 questions, I will reply you as below, if I missed any question please let me know:

  1. BingMapsLayer drawException cannot catch miss ApplicationID exception
    Your layer should been added into a LayerOverlay, please try to set the DrawingExceptionMode in the overlay at the same time. In my test it’s not thrown, if it still thrown in your side please let me know.

  2. What’s the difference between BingMapLayer, BingMapsOverlay and BingMapsTileOverlay
    BingMapsOverlay and BingMapLayer in WPF edition is the same, you can think choose anyone of them, the BingMapsTileOverlay have better performance, but it’s not suitable for your scenario, because it cannot match other base map well.

  3. Different GoogleMapsLayer and GoogleMapsOverlay
    You can think it’s the same in WPF edition.

  4. Reproject base map or reproject vector layer
    I suggest you project the vector layer, because we get tile image from server in base map, reproject it is not so well than reproject local data.

  5. Instantiate all layers and change the visibility of layers or instantiate the layer only when the user chooses the layer he wants to see
    If your layer is the base layers you mentioned, just instantiate them at the first time, user can accept application loading at the same time but maybe not accept it always loading. But if your layer is some special layer which will takes much time and maybe not all user will switch to it, you can load it when it is chosen.

Wish that’s helpful.

Regards,

Ethan

Hi Ethan

Thank you very much for your answer.
Indeed, I set drawingExceptionMode in the layer and that works. I did not have anymore the error message.

I have an other question about the cachedirectory of an overlay.
In our application, we have one layeroverlay for the basemap and we add 4 layers in (one for google, one for bing, one for osm, one for raster).
If the user change the basemap (switch osm to google for example), as we have one overlay the cache directory is the same and so the display is wrong.
The user sees the basemap of his map with Osm instead of google for tiles already cached;-(
Is there a hint to have the good display when the user swith of basemap with this configuration ?

I could have used the configuration of your example, you use an overlay for each basemap and each overlay has its own cachedirectory.
I think you advise not to have too many overlays on the map, because it slows wpf performance, that’s why I did not use this option.
(ie Best practice for using LayerOverlay and Layers?)

Thanks.

Regards.

Steph.

Hi Steph,

The cache is in overlay level, so if you open cache, no matter what layer is using in the overlay, it will render the same cache.

The solution is just like you mentioned, create different overlay for each cached base map, it will reduce the performance, but you can try it and see whether the speed is acceptable.

And you can set different cacheid for different layer, when you switch layer, you found the event of it, and change the cacheid (cache id in fact is the sub folder in cache folder), it can use different group of tile images for same overlay.

Wish that’s helpful.

Regards,

Ethan

Thanks, Ethan

Regards.
Steph.

Hi Steph,

Any update please let us know.

Regards,

Ethan