ThinkGeo.com    |     Blog    |     Wiki    |     Support

WMS-C Xamarin Forms

Hello ThinkGeo!

I have until now been using a WmsOverlay() to get my map from a custom WMS server.
These tiles are generated on request, but this caused my map to be somewhat slow during load, and tiles would take a while to load.

I then noticed that they offered WMTS/ WMS-C to improve the tilefetching speed. This is also available using the Google Maps protocol, and Bing maps protocol.

Is there a method within ThinkGeo Forms for me to use this map functionality?
Here is the link to the capabilites file of said WMS-C service.
http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts?Version=1.0.0&service=wmts&request=getcapabilities

Hi Jehans,

WMS-C has been superceded by WMTS. Please refer https://wiki.osgeo.org/wiki/WMS_Tile_Caching for detail.

Our product supports WmtsLayer, please refer below code:

LayerOverlay layerOverlay = new LayerOverlay();

WmtsLayer wmtsLayer = new WmtsLayer(new[] { new Uri("http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts") });
wmtsLayer.ActiveLayerName = "toporaster3";
wmtsLayer.ActiveStyleName = "default";
wmtsLayer.TileMatrixSetName = "EPSG:3857";
wmtsLayer.OutputFormat = "image/png";

layerOverlay.Layers.Add(wmtsLayer);
mapView.Overlays.Add(layerOverlay);

If you have any questions, please feel free to contact us.

Thanks,
Bill

Hi Bill!

I have some troubles getting the map to show. It sometimes shows up once very small on the map, but if I try to zoom it dissappears.
80% of the time it doesn’t show at all. This is the one of the last puzzle pieces remaining for our app project, and I am extremely grateful for all the good help so far.

I want to use the EPSG 32632 projection for my map, and the capabilites file show that the extent is

Here is my current code:

layerOverlay = new LayerOverlay();

        WmtsLayer wmtsLayer = new WmtsLayer(new[] { new Uri("http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts") });
        wmtsLayer.ActiveLayerName = "topo2";
        wmtsLayer.ActiveStyleName = "default";
        wmtsLayer.TileMatrixSetName = "EPSG:32632";
        
        wmtsLayer.OutputFormat = "image/png";
        layerOverlay.Layers.Add(wmtsLayer);

MapView mapview = new MapView();
mapView.MapUnit = ThinkGeo.MapSuite.Core.GeographyUnit.Meter;
customOverlay = new CustomOverlay();
mapView.Overlays.Add(“map”, customOverlay.getOverlay());

        mapView.CurrentExtent = new RectangleShape(-2000000.0, 9045984.0, 3545984.0, 3500000.0); //new RectangleShape(-2000000.0, 9045984.0, 3545984.0, 3500000.0);
        mapView.Refresh();

A little update here!

By using the URL http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts?Version=1.0.0&service=wmts&request=getcapabilities I can atleast get the map to show in QGIS the way I want to.

Using this URL In the app now returns tiles with “The CRS you provided is not supported by the layer”, however according to the capabilities it seems to be supported.

Does anyone have a clue on how to solve this?

Hi Jehans,

Thanks for your information.

This issue has fixed on version 9.0.674.0 and higher version, please download that with product center and have a try.

If you have any questions, please feel free to contact us.

Regards,
Bill

I have tried different URLs, with both MapUnit = Meter and DecimalDegree. I have also tried different Crs, but to no avail.
I am still getting “Crs not supported”, but I also now recieve an error on the tiles that says “this method will return to many cells that might cause performance problem” on tiles.

Hi Jehans,

We reproduce your problems.

Please refer the following list:

  1. The URL (http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts?Version=1.0.0&service=wmts&request=getcapabilities) is a getting capabilities request instead of WMTS server URL. WmtsLayer need WMTS server URL (http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts ).
  2. The “This method will return to many cells that might cause performance problem” issue cause by map unit isn’t matched with map extent. Please check the map unit and extent setting, and make sure them are consistent. The meter unit should use meter extent(max is -20037508, 20037508, 20037508, -20037508) , The decimal degree unit should use decimal degree extent(max is -180,90,180,-90).

If you still doesn’t resolve your problems, could you give me a demo to reproduce your problems?

Thanks,
Bill

Hi! Using your example, I simply get a blank screen, without any tiles loaded.
Seen below is the a demo for achieving the same results:

        MapView mapView = new MapView();

        mapView.MapUnit = ThinkGeo.MapSuite.Core.GeographyUnit.DecimalDegree;

        LayerOverlay layerOverlay = new LayerOverlay();

        WmtsLayer wmtsLayer = new WmtsLayer(new[] { new Uri("http://opencache.statkart.no/gatekeeper/gk/gk.open_wmts") }); //
        wmtsLayer.ActiveLayerName = "topo2";
        wmtsLayer.ActiveStyleName = "default";
        wmtsLayer.TileMatrixSetName = "EPSG:32632";
        wmtsLayer.OutputFormat = "image/png";
        layerOverlay.Layers.Add(wmtsLayer);
        mapView.Overlays.Add("map", layerOverlay);

        mapView.CurrentExtent = new RectangleShape(-180, 90, 180, -90);

        mapView.HorizontalOptions = LayoutOptions.FillAndExpand;
        mapView.VerticalOptions = LayoutOptions.FillAndExpand;
        mapView.BackgroundColor = Color.FromRgb(255, 255, 255);
        mapView.MinimumHeightRequest = 500;
        mapView.HeightRequest = 500;

        mapViewWrapper = new StackLayout();
        mapViewWrapper.HorizontalOptions = LayoutOptions.FillAndExpand;
        mapViewWrapper.VerticalOptions = LayoutOptions.FillAndExpand;
        mapViewWrapper.Children.Add(mapView);

        StackLayout contentView = new StackLayout()
        {
            Padding = 0,
            Orientation = StackOrientation.Vertical,
            Children = {
                        mapViewWrapper
                    }
        };
        contentView.BackgroundColor = Color.White;
        Content = contentView;

Small update here!

Changed to GeographyUnit.Meters, and CurrentExtent to (-2000000.0, 9045984.0, 3545984.0, 3500000.0) and it made the map show up! Thank you for all your support!

Although, it is very slow, but I will test more of their servers.

Will continue to update.

EDIT:

Another update:
If I enable TileCache, I get the error “This key does not exist in the dictionary” where the tiles are supposed to load for all tiles.
I noticed that the TileSnappingMode is not a valid parameter here, as found within WmsOverlay.

It is also extremely slow to load tiles. It takes up to 20-30 seconds to load a screen with tiles, and it can take up to 10 seconds before a single tile has loaded. What might seem like an error message that I receive is that the amount of threads increase by alot during map load. As much as 200 at the time.

"hill climbing, change max number of threads 157"

I tested the same map, with the same internet connection within QGIS, and the tiles here seemed to appear within normal loading time.

Hi Jehans,

Please refer the following list:

  1. We create a sample to reproduce the tile cache issue. This is a bug, our developer is going to fix it, Any progress will let you know.
  2. The “hill climbing, change max number of threads 157” output is not error message. It only shows the max number of threads. Map loads tiles by multi-thread, after map loaded tiles, the threads will be closed.
  3. QGIS is a desktop software. Android performance is limited by device. Usually, the mobile device performance is lower than desktop. We test our wpf product, it is as fast as QGIS.

If you have any question, please feel free to contact us.

Thanks,
Bill

Hi Jehans,

We have fixed the tile cache issue for WmtsLayer. Please download the version 9.0.681.0 or higher version on ProductCenter.

If you have any questions, please feel free to contact us.

Thanks,

Thank you Bill!
Will test it now
Edit: It is not yet available through Product Center here.

Hi Jehans,

We have uploaded version 9.0.681.0 to ProductCenter. Please download and have a try.

If there is any question, please feel free to contact us.

Thanks,
Bill

Update here - The slow bug im talking about is only for Android. iOS works very well!
And ThinkGeo is currently solving the Android bug. Thanks!

Hi Jehans,

We will update the status of WMTS slow problem in your ticket.

Regards,

Don