Hi Ben,
Unfortunately we are still having a variety of issues including:
-
Tiles look muddled up. I think they are the correct tiles but definitely in the wrong order and I have not picked up a pattern for how they are disarranged.
-
As you zoom in the tiles have gaps between
-
Adding a projected tile cache causes an error that shows as the message ‘Arithmetic operation resulted in an overflow’ instead of actual tiles.
The code looks like this:
private static void InitialiseBackgrounds(MapView mapControl)
{
// If the setting exists in the setting file, then osMapsAPIKey will come out with its corresponding value and it returns true
// Otherwise it returns false (meaning the osMapsAPIKey will contain an empty value) and we set it to the default key
// To add a user key use a line like this in the setting file:
// <OSMapsAPIKey>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</OSMapsAPIKey>
Setting settings = new Setting(Setting.Usage.DEFAULT, Setting.Areas.GENERAL);
if (!settings.GetSettingsValues().TryGetValue(Setting.GeneralKeys.OSMAPS_API_KEY, out _osMapsAPIKey))
SetStandardOSKey();
if (!settings.GetSettingsValues().TryGetValue(Setting.GeneralKeys.MAPBOX_API_KEY, out _mapboxAPIKey))
SetStandardMapBoxKey();
osMapLayer = new WmtsAsyncLayer(new Uri("https://api.os.uk/maps/raster/v1/wmts"))
{
Name = OS_BACKGROUND,
AxisOrder = WmtsAxisOrder.XY,
DrawingExceptionMode = DrawingExceptionMode.DrawException,
WebProxy = null,
ActiveLayerName = "Road_27700",
ActiveStyleName = "Road",
TileMatrixSetName = "EPSG:27700",
IsVisible = true,
OutputFormat = "image/png",
};
osMapLayer.TileCache = CreateCacheForLayer(osMapLayer.ActiveLayerName, MapBackgroundLayerStyle.OSAPI);
osMapLayer.SendingHttpRequest += OsMapLayer_SendingHttpRequest;
mapBoxLayer = new WmtsAsyncLayer(new Uri("https://api.mapbox.com/styles/v1/lukeor/ckfy0j3ye01d019pfob9re2zi/wmts"))
{
Name = MAPBOX_BACKGROUND,
AxisOrder = WmtsAxisOrder.XY,
DrawingExceptionMode = DrawingExceptionMode.DrawException,
WebProxy = null,
ActiveLayerName = "ckfy0j3ye01d019pfob9re2zi",
ActiveStyleName = "default",
TileMatrixSetName = "GoogleMapsCompatible",
ProjectionConverter = new GdalProjectionConverter(3857, 27700),
IsVisible = true,
};
mapBoxLayer.TileCache = CreateCacheForLayer(mapBoxLayer.ActiveLayerName, MapBackgroundLayerStyle.SATELLITE);
mapBoxLayer.ProjectedTileCache = CreateCacheForLayer(mapBoxLayer.ActiveLayerName, MapBackgroundLayerStyle.SATELLITE_PROJECTED);
// Include the key as a parameter
mapBoxLayer.Parameters.Add("access_token", _mapboxAPIKey);
wmtsBackgrounds.Name = WMTS_OVERLAY_NAME;
wmtsBackgrounds.Layers.Add(MAPBOX_BACKGROUND, mapBoxLayer);
wmtsBackgrounds.Layers.Add(OS_BACKGROUND, osMapLayer);
mapControl.Overlays.Add(WMTS_OVERLAY_NAME, wmtsBackgrounds);
mapControl.Overlays.MoveToBottom(wmtsBackgrounds);
}