Page 1 of 1

Hybrid View

Posted: Fri Jul 29, 2016 12:39 pm
by GuenterWestphal
Hello everybody,

I would like to know how to create a hybrid view of a map, i.e., a semi transparent map plus the corresponding satellite image on top of it, in C#. The xMap class provides two functions renderMapBoundingBox() and renderMap(), respectively, that provide an image of the requested map but I find it rather unclear how to place the corresponding satellite image (HERE maps) onto that map with the "right" scale and in fashion that the maps really fit, i.e., that the streets are really located on top of each other. In the Javascript API there was a function addTiledAerialLayer(). Alas, in the C# API I cannot find a similar function.

Thus, to cut a long story short: How is it done? Can you provide me with a code snippet that pushes me in the right
direction?

Thanks in advance,

Günter

Re: Hybrid View

Posted: Mon Aug 01, 2016 8:19 am
by Oliver Heilig
Hello Günter,

the aerial integration in Javascript and .NET is usually implemented for the according client-controls (ajaxmaps or xServer.NET). If you want to create static images with a hybrid view, you must mesh-up it on your own. This is rather complex, as you have to stitch the HERE tiles to a single map, but there are Open-Source libraries that can do that. SharpMap https://www.nuget.org/packages/SharpMap/ for example allows to mesh-up imagery data from different sources in C#. You can also use it to render you own data source with SharpMap.

I've built a project that shows how to use SharpMap to create interactive and static maps from different sources: https://github.com/ptv-logistics/SharpMap.Widgets. The Project SharpMap.Print creates a static image that combines xMapServer and custom data, but you can also use it for a HERE/xMap mesh-up:

The class XMapLayer implements a SharpMap-Layer using PTV xMapServer:
https://github.com/ptv-logistics/SharpM ... apLayer.cs
The class HereSatelliteRequest contains the request-scheme for HERE aerial images:
https://github.com/ptv-logistics/SharpM ... Request.cs

You can overlay these two images by first inserting the HERE tiles and then a semi-opaque xMapServer layer:

Code: Select all

// HERE satellite images
sharpMap.Layers.Add(new Layers.TileLayer(new TileSource(new WebTileProvider(new HereSatelliteRequest()
{ AppId = "<your app id>", AppCode = "<your app code>" }, new NullCache()),
new SphericalMercatorInvertedWorldSchema()), "HERE"));

// xmap-bg
sharpMap.Layers.Add(new XMapLayer("xmap-bg", "https://api-eu-test.cloud.ptvgroup.com/xmap/ws/XMap", MapMode.Background)
{ User = "xtok", Password = token, Opacity = 0.5F  }); // set semi-opaque for hybrid view
The result is a hybrid image:
xMapHere.png


By the way: The new xMap-2 will support a true alpha-channel. This allows you to build a road-only overlay. You can apply for a preview-access for xServer-2 and then use this implementation:
https://github.com/ptv-logistics/SharpM ... equests.cs
xMap2Here.png
Regards
Oliver

Re: Hybrid View

Posted: Mon Aug 01, 2016 2:42 pm
by GuenterWestphal
Hi Oliver,

works like charm. Thank you very much!

Kind Regards,

Günter

Re: Hybrid View

Posted: Wed Oct 05, 2022 2:19 pm
by Bernd Welter
Cheerio!

HERE has changed the authentication method - Please consider this article!

Best regards,
Bernd