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
Hybrid View
- Oliver Heilig
- Posts: 160
- Joined: Tue May 13, 2014 12:10 pm
- Location: Karlsruhe, Germany
- Contact:
Re: Hybrid View
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:
The result is a hybrid image:
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 Regards
Oliver
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
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 Regards
Oliver
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany
https://github.com/oliverheilig/
Chief Developer Logistic Services
PTV GROUP - Germany
https://github.com/oliverheilig/
-
- Posts: 5
- Joined: Thu Jul 28, 2016 11:52 am
Re: Hybrid View
Hi Oliver,
works like charm. Thank you very much!
Kind Regards,
Günter
works like charm. Thank you very much!
Kind Regards,
Günter
- Bernd Welter
- Site Admin
- Posts: 2695
- Joined: Mon Apr 14, 2014 10:28 am
- Contact:
Re: Hybrid View
Cheerio!
HERE has changed the authentication method - Please consider this article!
Best regards,
Bernd
HERE has changed the authentication method - Please consider this article!
Best regards,
Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany
Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning...
Technical Partner Manager Developer Components
PTV Logistics - Germany
Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning...