ThinkGeo.com    |     Documentation    |     Premium Support

TG14.3 - MBTiles - Error?

Hi,
Using a VectorMBTilesAsyncLayer, which was working just fine in TG14.1, now updated to TG14.3 and it’s stopped working!

An error is thrown on RefreshAsync():
System.InvalidOperationException: The requested operation requires an element of type ‘Number’, but the target element has type ‘String’

The source MBTiles data is the same and in the same location, the code has not changed, the only thing that has changed is ThinkGeo updated to 14.3…
I have recreated the exact same issue with a new, clean app that houses nothing but the ThinkGeo map control and the simple code I’ve posted below.

Any ideas?
Thanks,
Jason.

code used:

private async void MapView_Loaded(object sender, RoutedEventArgs e)
{
    thinkgeoMap.MapUnit = GeographyUnit.Meter;
    LayerOverlay vectortileOverlay = new LayerOverlay();

    vectortileOverlay.TileType = TileType.SingleTile;
    thinkgeoMap.Overlays.Add(vectortileOverlay);
    var layer = new VectorMbTilesAsyncLayer(@"C:\Mapping\MBTiles\Zoomstack\OS_Open_Zoomstack.mbtiles", @"C:\Mapping\MBTiles\Zoomstack\OS Open Zoomstack - Roads.json");
    vectortileOverlay.Layers.Add(layer);

    await thinkgeoMap.RefreshAsync();
}

just let you know it’s recreated and we are working on it.

Jason, can you send me the OS Open Zoomstack - Roads.json you are using?

Jason,

We’ve made some improvements on the vector mbtiles, can you pull the latest beta v14.4.0-beta029 and have another try? It should be working with the OpenStack data and you should also see performance improvements.

VectorTile is one of the high priorities on our list and we will be keep working on it.

Thanks,
Ben

Sorry Ben, was on leave - do you still need the json file?
Thanks

Please send it over to us if your json doesn’t work.

Just FYI, we just made some improvements in the latest version beta030, to support the uris starting with “mapbox://”.

Hi Jason,

Please pull the latest beta (14.4.0-beta031), which works fine with your styleJson, in either of the following way:

 // #1, use VectorMbTilesAsyncLayer
 var mbTilesLayer = new VectorMbTilesAsyncLayer("OS_Open_ZoomStack.mbtiles",
                                "OS Open Zoomstack - Road.json");

 // #2, use MvtTilesAsyncLayer
 // the following code loads the mbtiles which is defined in the json. 
 var mvtLayer = new MvtTilesAsyncLayer("OS Open Zoomstack - Road.json");

Have a try and let us know if you see any issues.

Thanks,
Ben

1 Like

Thanks Ben, the latest Beta does indeed fix the MBTiles issue! :trophy:
However, as discussed it also introduces a problem with ShapeFileFeatureLayers (see attached)


I’ll forward on an example of our code later today…
Thanks,
Jason.

Example code as promised:

    private async void MapView_Loaded(object sender, RoutedEventArgs e)
    {
        thinkgeoMap.MapUnit = GeographyUnit.Meter;
        LayerOverlay shapefileOverlay = new LayerOverlay();

        var layer = new ShapeFileFeatureLayer(@"C:\Mapping\ShapeFileOverlays\Station Boundaries\Station Boundaries.shp");

        var redGeoColorSolid = new GeoColor(255, 0, 0);
        var redGeoColorTransparent = new GeoColor(64, 255, 0, 0);
        var redPenSolid = new GeoPen(redGeoColorSolid, 3);
        var redBrushTransparent = new GeoSolidBrush(redGeoColorTransparent);

        var redPointStyle = new PointStyle(PointSymbolType.Circle, 12, redBrushTransparent, redPenSolid);
        var redAreaStyle = new AreaStyle(redPenSolid, redBrushTransparent);
        var redLineStyle = new LineStyle(redPenSolid);
        var redTextStyle = new TextStyle("textString", new GeoFont("Arial", 12), new GeoSolidBrush(GeoColors.Black));

        var gfont = new GeoFont("Arial", 10);
        var redSymbolStyle = new PointStyle(gfont, "0", redBrushTransparent);

        var defaultStyles = new ThinkGeo.Core.Style[] { redPointStyle, redAreaStyle, redLineStyle, redTextStyle, redSymbolStyle };
        ThinkGeo.Core.Style defaultstyle = new CompositeStyle(defaultStyles);

        layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(defaultstyle);
        layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

        shapefileOverlay.Layers.Add(layer);
        thinkgeoMap.Overlays.Add(shapefileOverlay);

        layer.Open();
        var bb = layer.GetBoundingBox();
        thinkgeoMap.CenterPoint = bb.GetCenterPoint();
        thinkgeoMap.CurrentScale = 6000;
        layer.Close();

        await thinkgeoMap.RefreshAsync();
    }

Jason, it’s a bug in CompositeStyle, and has been fixed in 14.4.0-beta034. Pull the latest and have a try.

Thanks,
Ben

Awesome, Thanks Ben, looks good.
:+1:

Cheers,
Jason

You are welcome, Jason!