Hi!
I want to cache a WmsOverlay in my application, and is wondering what method/properties I should use. I have looked trough the docs and samples, but the docs are not to informative, and the samples does not cache maps. Any tips?
Best regards,
Kristoffer
Caching of WmsOverlay
Hi Kristoffer,
We tried to use our IOS and Android edition API works just like our other product, so I think you can use WmsOverlay.TileCache for cache, does that don’t works?
Regards,
Don
Hi! I found that just before I left work yesterday, so will try it out on a device today to see that i actually works outside in the field.
Tried to look for it in the documentation, but the docs for Map Suite iOS is awful, so that is why I tried the forum instead.
This is just not good enough:
N/A
Remarks
N/A
Return Value
-
Type:BitmapTileCache
Hi Kristoffer,
We will complete the documentation follow the IOS edition upgrade, thanks for let us know that.
Regards,
Don
If I have understood correct, the caching mecanism caches the layer one are looking at in the map and nothing more?
Would be great to cache/save for example 4-5 layers or more for an offline-mode support.
Is it also possible to use SQLite and not only files?
Regards,
Kristoffer
Hi Kristoffer,
Yes, the SQLite can be supported as the Cache, but not available now. It may be integrated in future. As I understood, there are meanings of layers, just outline them as following with their solution, please check it out.
1. The layer of WMS service, in that case, you need to create 4-5 WmsOverlays for each WMS “Layer” parameter for seperate cache. But I guess you can make all of them in one WmsOverlay as well, as the images from a WMS Service should be static, in other words, no changes, right?
2. The layer means the normal layers, thus you need to create their corresponding LayerOverlay and apply TileCache to its LayerOverlay for offline-mode support.
If I’m not correct, would you please clarify your requirements here with more details?
Thanks,
Johnny
I am sorry, I was unclear, what i ment was caching of more then one Zoom-level, so the user can zoom in and out 2-3 levels while in offline mode.
Regards,
Kristoffer
Hi Kristoffer,
Thanks for your clarify in the email, I see I understand now that you just would like to cache for some specified zoom levels of WmsOverlay, right? In that case, I don’t think we doesn’t provide any straight-forward method to implement it, but a workaround is using the UpperThreshold and LowerThreshold instead. In other words, if you would like to create the cache for from zoom level 4 to zoom level 7, you need to use WmsRasterLayer instead, the code should be look like as following:
ZoomLevelSet zoomLevelSet =
new
ZoomLevelSet();
WmsRasterLayer cachedWmsLayer =
new
WmsRasterLayer(
new
Uri(
"<a href=“howdoiwms.thinkgeo.com/WmsServer.aspx">howdoiwms.thinkgeo.com/WmsServer.aspx</a>"
));
cachedWmsLayer.UpperThreshold = zoomLevelSet.ZoomLevel07.Scale;
cachedWmsLayer.LowerThreshold = zoomLevelSet.ZoomLevel04.Scale;
cachedWmsLayer.ActiveLayerNames.Add(
“layernames”
);
cachedWmsLayer.ActiveStyleNames.Add(
“Simple”
);
LayerOverlay cachedOverlay =
new
LayerOverlay();
cachedOverlay.TileCache =
new
FileNativeImageTileCache(…);
cachedOverlay.Layers.Add(
“cachedWmsLayer”
, cachedWmsLayer);
mapView.Overlays.Add(cachedOverlay);
WmsRasterLayer nonCachedWmsLayer =
new
WmsRasterLayer(
new
Uri(
”<a href="howdoiwms.thinkgeo.com/WmsServer.aspx">howdoiwms.thinkgeo.com/WmsServer.aspx</a>"
));
nonCachedWmsLayer.UpperThreshold =
double
.MaxValue;
nonCachedWmsLayer.LowerThreshold = 0;
nonCachedWmsLayer.ActiveLayerNames.Add(
“layernames”
);
nonCachedWmsLayer.ActiveStyleNames.Add(
“Simple”
);
LayerOverlay nonCachedOverlay =
new
LayerOverlay();
nonCachedOverlay.Layers.Add(
“nonCachedWmsLayer”
, nonCachedWmsLayer);
mapView.Overlays.Add(nonCachedOverlay);
You see there are 2 LayerOverlay and WmsRasterLayer declared, the first one is applied TileCache, but it’s just used for the scales between zoom level 4 and 7, and the later one doesn’t have TileCache, but it works for all Zoom Levels. If we take the performance into account, it’s better we can create 2 non-cached overlays, one is for scales from 0 to zoom level 4, and another for zoom level 7 to zoom level 20.
Please let me know if it helped.
Thanks,
Johnny
This is what i am looking for yes. I know it will create some performance issues, but offline support is a demand. But, when i run the code it always crashes. and it is these to lines:
mapView.Overlays.Add(cachedOverlay);
mapView.Overlays.Add(nonCachedOverlay);
If i run my app without these two lines, it runs, but if i comment them in again the app crashes with an exception without any text to explain what happend. Any idea why?
Kristoffer
As far as I can see the issue is with Apples SDK, and not ThinkGeo, so i will get an physical device tomorrow from my PL and then try it out again.
But, do you have any examples of MapSuite using vectortiles? We are also thinking about this as an alternative for WMS.
Kristoffer
Hi Kristoffer,
Johnny’s sample just shows how to use the API, you should replace the WMSServer url, cache folder name, active name, active style. Please test it after you modify them.
And I am sorry I don’t very sure about your last question, what is the vectortiles? Do you mean you want to use local cached tile instead of get times from WMS?
Regards,
Don