Hi,
We would like to add a layer with mapbox raster in our wpf application.
For Google or Bing layers, there are the layers GoogleMapsLayer and BingMapLayers. (layers represents
an object that encapsulates a Google Map layer or Bing Map Layer).
But for mapbox, the layer extension does not exist.
How to add a layer with the mapbox baseMap in a wpf application? Or how to call the Api MapBox ?
Thanks a lot for your help.
Regards.
Steph.
How to use MapBox as BaseMap in a wpf application?
Hi Steph.
Our WPF edition don’t have a overlay for MapBox, but you can implement that by your custom code.
The url for MapBox should looks like: http://api.tiles.mapbox.com/v4/“mapid”/“z”/“x”/“y”.png?access_token=“your access token”
You can just implement a custom class which is inherited from our TileOverlay class, then override the GetTileCore and DrawTileCore function to implement your logic, then it should works.
Any question please let us know.
Regards,
Ethan
Hi Ethan,
Thank you for your reply.
I still have some questions.
When using BingMapsOverlay in a application for example, I imagine that this overlay encapsulates a layer of BingMapLayer.
It is not better to create a MapBoxLayer that inherits from layer …?
And then use this layer and add it in a classic overlay?
If we use the following API:
https://api.mapbox.com/v4/mapbox.satellite//{zoom}/{x}/{y}{@2x}.{format}?access_token=MyToken
How to signify the zoom level mapping between Map thinkgeo and the return of the image api? {zoom}
Same for to properly position the returned images in the map ? {y} {y}
Thank you very much for your help.
Regards.
Steph.
Hi Steph,
Because for XXXMapsOverlay and XXXMapsLayer, we implement them follow different way in different product. In some edition, the XXXMapsOverlay is a wrapper of XXXMapsLayer, but in some edition, they are totally different to require different server library. We keep them in our products to make user feel better when switch between different versions, and most of the code can be directly used without modify.
You can add the XXXMapsLayer into classic overlay, it should works.
If you want to implement a custom layer for example the mapbox, to make it works better, you should want to build a custom zoomLevelSet to make the tile image match without stretch. You can see we have the custom zoomlevel for Bing and Google. Generally you don’t need think about it and just choose the default zoomlevel set, it should works.
Wish that’s helpful.
Regards,
Ethan
I know this is an old topic, but we also want to use MapBox. We do not know how to create a “custom class which is inherited from our TileOverlay class”. Can you please provide sample C# code for how to do this?
For example, to load OpenStreetMaps, we use the following code:
if (SelectedMapOverlayIndex == OpenStreetMap)
{
OpenStreetMapOverlay osmMapsOverlay = new OpenStreetMapOverlay();
osmMapsOverlay.DrawingExceptionMode = DrawingExceptionMode.DrawException;
osmMapsOverlay.TileCache = new FileRasterTileCache(MAP_CACHE_FOLDER, MAP_CACHE_OSM, GeoImageFormat.Png);
mapView.Overlays.Insert(0, "osmMapsOverlay", osmMapsOverlay);
}
Hi @Damian2,
Sorry for the delay, but yesterday was a holiday here in the states. We’ve greatly improved our support for MapBox since this post was started. I assume you’re needing to use a MapBox Vector Tile layer (MVT). These days the vector tiles layer is much more common.
If that’s the case, then you can look into our ‘HowDoI’ samples and check out the Map Online Data --> MVT sample. This uses the MvtTilesAsyncLayer class to point to a MapBox .json file which in turn has a datasource of vector tiles. Please check out this sample as well as the XYZ Based Layers --> Display Vector From MVT sample and let us know if that works for your scenario.
Thanks,
John