ThinkGeo.com    |     Documentation    |     Premium Support

Layer/Tile Caching

We are looking into rewriting our existing mapping application that uses MVC Edition and we are considering switching over to the WebAPI Edition. We dynamically load several InMemoryFeatureLayers based on queried database tables. This data can be modified by the user at anytime and the layers will vary as the user changes from customer to another. With the MVC Edition we have the benefit of loading all of our layers to the ThinkGeo.MapSuite.Mvc.Map. This works well as all the tile generation requests are handled via the thinkgeo openlayers javascript. The additional benefit is that the database is queried once to load the layer and it is not necessary to “requery” the data for each tile generated for the layer. If the user modifies any of the data associated to the layer or switches to another customer we simply reload the layers on to the Map and refresh the map in the UI with the updated data. None of this requires any custom caching of data, layers, or tiles.

My question is does this concept exist in the WebAPI edition or is there a way to implement it?

I downloaded your Hello World example (https://github.com/ThinkGeo/HelloWorldSample-ForWebApi) and even this simple example reloads the State shape file for every tile request made by the Leaflet API to the GetTile method in the HellowWorldController. Hopefully I am just missing a concept in WebAPI.

Thanks
Greg

Hi Greg,

The WebAPI version focus handle the server side, this product don’t contains client side logic, we provide the Leaflet and Openlayers as client side in sample is just a guide.

And I don’t think your original logic don’t need to requery data when the data get changed, unless your code cache the data somewhere. Because the cache is only work for fixed data, any data get changed, we need remove old cache and generate the new version.

So please make sure whether you cached the data in your original mvc project, or you directly modify the data in client side, and post the change to server side but not get response, that’s why it don’t need to query again.

If your project cache the data in client side, you should want to implement that by the client library you choose. If that’s modify data in client side and only post the change to server side, you can do the same thing in WebAPI edition.

Regards,

Ethan

In the MVC Edition I load a layer once either through a custom data set or a shape file and once the layer has been loaded and presented in the UI the tiles are downloaded and displayed on the map. On each tile request the layer does not have to be reloaded with the data or shape file.

Compared to your WebAPI sample, https://github.com/ThinkGeo/HelloWorldSample-ForWebApi, each tile request requires a complete load of the layer. So, if the map requires 20 tiles the MVC version only requires me to load the layer one time where WebApi will load it 20 separate times or at least according to this example.

Basically what I want to know is there a way to avoid having to load a layer in WebAPI for every tile request?

Hi Greg,

Just like I mentioned in the last reply, the webapi focus on server side.

I don’t know how you save cache in MVC edition for the downloaded tiles, but the MVC edition is also supported by OpenLayers library, if the MVC edition can make it works, you can also implement that in client side when you choose webapi edition.

So I think that’s should be possible, the detail solution you should want to do some research based on the client side library for example the Leaflet. For example I found a topic discuss about how to implement offline map, which should be saved in client side: https://stackoverflow.com/questions/16036880/how-to-make-offline-mapsusing-leaflet-osm-by-caching

Regards,

Ethan