ThinkGeo.com    |     Documentation    |     Premium Support

Xamarin Forms - WmsOverlay and TileCaching

Hi Thinkgeo!

I do enjoy your product for Xamarin Forms, but I am struggling somewhat with finding the correct documentation that I need.

I am working with WmsOverlay from a custom WMS server, and I need help with two topics.

1 - Not all tides load on the map. Sometimes all on screen load, but not always. See photo below. I would like to debug why this happens, does anyone have an idea on how to do this? A tile that doesnt load when I run the app, might load when I move away from current extent, and back again to the same area

.

2 - I use WmsOverlay to access my server, but a requirement for my application is that offline caching is enabled. I have understood that the TileCache class is the way to go, as can be found in Google Maps overlay, and world map kit overlay. However, not in WmsOverlay. Can anyone tell me the best practice for this? Below is the code I have used for WmsOverlay.

wmsOverlay.ServerUris.Add(new System.Uri("http://openwms.statkart.no/skwms1/wms.topo2?"));
         wmsOverlay.Parameters.Add("LAYERS", "topo2_WMS");
         wmsOverlay.Parameters.Add("SRS", "EPSG:4326");//#
         wmsOverlay.Parameters.Add("FORMAT", "image/jpeg"); //#
         wmsOverlay.Parameters.Add("STYLES", "default");
         wmsOverlay.Parameters.Add("VERSION", "1.3.0");
         wmsOverlay.Parameters.Add("EXCEPTIONS", "XML"); 
         wmsOverlay.Name = "WMS";

Hi Jehans,

  1. That should because the network issue, it make the tile request failed, so when you pan and pan back, it will render again. I think you can open cache for solved that.

  2. The cache for wmsoverlay should looks like this: wmsOverlay.TileCache = new FileBitmapTileCache(“your cache path”);

Wish that’s helpful.

Regards,

Don

Hi Don, and thanks for the answer! Im making progress here :slight_smile:

1 - That makes sense.
2 - The TileCache property does not exist for WmsOverlay, such as found within GoogleMapsOverlay.
My current code looks like pasted below, however I guess I have to make a connection somehow between WmsOverlay and the TileCache?

WmsOverlay wmsOverlay = new WmsOverlay();
    TileCache TileCache { get; set; }
    public CustomOverlay()
    {
        wmsOverlay.ServerUris.Add(new System.Uri("http://openwms.statkart.no/skwms1/wms.topo3?"));
        wmsOverlay.Parameters.Add("LAYERS", "topo3_WMS");
        wmsOverlay.Parameters.Add("SRS", "EPSG:4326");//4326
        wmsOverlay.Parameters.Add("FORMAT", "image/png"); //#
        wmsOverlay.Parameters.Add("STYLES", "default");
        wmsOverlay.Parameters.Add("VERSION", "1.3.0");
        wmsOverlay.Parameters.Add("EXCEPTIONS", "XML"); 
        wmsOverlay.Name = "WMS";
        TileCache = new FileBitmapTileCache("cache");   
    }

Hi Jehans,

Are you using Android edition or MapSuiteFormsEdition(Xamarin)? Our Android edition support cache but it looks forms edition don’t contains that.

Your code won’t works for cache because just like you said, it doesn’t connect cache and overlay.

Regards,

Don

Hello Don,

I am using the Forms edition.
Do you have a suggestion for the best way of getting caching offline to work for Xamarin Forms?
Is there any way that I could “hack” the WmsOverlay to forexample a Google Maps Overlay that has caching implemented?

Hi Jehans,

Our developer will take some time to see whether we can make the cache works for Xamarin Forms.

Please wait out update about that.

Regards,

Don

Thank you so much for the great service Don, and the other developers at Thinkgeo!
It would make me extremely happy if it is possible :slight_smile:

Hi Alexander,

We have made the cache works for Xamarin Forms. Please download the 9.0.615.0 or higher version from our product center to get this enhancement.

Please set WmsOverlay like this:
WmsOverlay wmsOverlay = new WmsOverlay();
wmsOverlay.ServerUris.Add(new System.Uri("http://openwms.statkart.no/skwms1/wms.topo3?"));
wmsOverlay.Parameters.Add(“LAYERS”, “topo3_WMS”);
wmsOverlay.Parameters.Add(“SRS”, “EPSG:4326”);//4326
wmsOverlay.Parameters.Add(“FORMAT”, “image/png”); //#
wmsOverlay.Parameters.Add(“STYLES”, “default”);
wmsOverlay.Parameters.Add(“VERSION”, “1.3.0”);
wmsOverlay.Parameters.Add(“EXCEPTIONS”, “XML”);
wmsOverlay.Name = “WMS”;
wmsOverlay.TileSnappingMode = TileSnappingMode.Snapping;
wmsOverlay.TileCache = new FileBitmapTileCache(dataPath, “Topo3_WMS”);

Thanks,

Best service I ever got from a software company. Thanks alot guys!

Hi Jehans,

I am glad to hear that’s helpful.

Regards,

Don

One last request for help here, as I cannot seemd to find version 9.0.615.0 in the product center.

In the product center, the newest Xamarin Forms build I can find is version 9.0.602.0 14/02/2017 for iOS, and Android 9.0.590.0 02/02/2017.

Would I have to re-download the product center software itself?

Hi Jehans,

Our manager had updated the download link in product center, I think you can download that later today.

Regards,

Don

Now I see it.

Thank you yet again for the good service.

Hi Jehans,

I am glad to hear you get the updated package.

Regards,

Don