raptorswing / MapGraphics

A tile-based "slippy map" library written in/for C++/Qt. It's meant to enable C++/Qt developers to easily add nice, interactive maps to their applications. Supports zooming, rotating, interactive custom map objects, transparency, etc. It is a Qt map widget that can use tiles from MapQuest, Openstreetmap, or a custom source you define.
Other
163 stars 77 forks source link

Can offline tiles be loaded #35

Open kunalkhosla93 opened 10 months ago

kunalkhosla93 commented 10 months ago

Hi,

Is it possible to load offline tiles from a directory using this? if so how?

raptorswing commented 9 months ago

Hi. Sorry for the slow response. It is possible, but might require a bit of effort. The code supports different "Tile Source" implementations. These can have their own implementations for loading tiles (e.g. HTTP requests, drawing on the fly, or loading from disk). There isn't one built-in for loading from disk, but the base class that they all inherit from does have the ability to store downloaded/rendered tiles to a disk cache and then load from there instead of hitting the network or rendering the tiles again.

See, for example, parts of the caching implementation in MapTileSource: https://github.com/raptorswing/MapGraphics/blob/0cf9af2104f545b3ec279772ef582feae304c4d1/MapGraphics/MapTileSource.cpp#L169-L219

You could conceivably implement a tile source that reuses this caching functionality, or maybe do something else. In either case, you'll probably want to implement a child class of MapTileSource.