Composant Delphi / Google Maps / OpenStreetMap / Leaflet  / Mappilary / Native Maps 100% Delphi 0% WebBrowser 0% Javascript

Offline mode

you are here :TECNativeMap

The tiles are first searched in the memory cache (the tiles displayed recently), the local cache, archive local then on the internet if need.

Local cache

By assigning a directory to LocalCache property internet downloaded tiles are saved locally and are available offline.

Fig. 72 My local tiles

Use the MaxDayInCache property to specify the duration of retention in the cache by default 30 days, 0 for an infinite cache.

map.MaxDayInCache := 7; // max 7 days

Archive local

An archive local is the local cache in a Zip, this simplifies deployment of the tiles and other files.

To improve the speed, the tiles are extracted from archive and placed in the local cache during the first request, you must set a local cache to use an archive.

Fig. 73 Archive ile de ré

map.LocalCache := TPath.Combine(TPath.GetSharedDocumentsPath, 'cache');
map.TileServer := tsOSM;
map.LocalArchive := ExtractfilePath(ParamStr(0))+'';

If roads or geolocations of addresses are saved in archive recovery is completely transparent

// if an archive is connected and contains the route, no internet connection is made to return the way
map.Routing.Request('saint-martin de ré', 'la couarde sur mer');

You can store your images or data files (kml, geojson etc...), to load start the name of the file by /

// load data
// load image in marker
marker.filename := '/IMAGE/node.png';

Use MapArchive to directly manipulate your archive and retrieve other data.

m := TMemoryStream.Create;





This small utility allows you to create your archives, you can download areas of tiles, save routes, add images and files.

Fig. 74 MapArchiveCreator

You can ban any internet connection for the tiles and geocoding using the property OnlyLocal

// tiles and geocoding only uses local cache and local archive
map.onlyLocal := true;

Download full a zone

The TECDownLoadTiles class allows you to download in the background one complete zone, the EcNativeMapFiremonkeyDemo shows you how to preload the viewable area on the screen.


FECDownLoadTiles.OnDownLoad := doDownLoadtiles;
FECDownLoadTiles.OnEndDownLoad := doEndDownLoadtiles;

// tiles are saved in DirectoryTiles
FECDownLoadTiles.DirectoryTiles := map.LocalCache;

FECDownLoadTiles.TileServer := map.TileServer;
FECDownLoadTiles.TileSize := map.TileSize;

// download visible area from zoom+1 to MaxZoom



// for abort

// see ECNativeMapFiremokeyDemo for complete use

Make sure that your provider of tile allows it !


Fill the Stream of tiles

You can also directly return a stream containing the jpeg or png of your tiles, useful if you have your tiles in a database.

procedure TForm.getTileStream(var TileStream: TMemoryStream;const x, y, z: integer);
// here fill the stream with your tile


procedure TForm.FormCreate(Sender: TObject);

map.TileServerInfo.GetTileStream := getTileStream;
map.TileServerInfo.Name := 'MyStream';
map.TileServerInfo.TileFormat := stJpeg; // or stPng
// called last, if not the first display is not performed
map.TileServer := tsOwnerDraw;


Also allows to use a Server's remote tiles.

go to page
© 2016 ESCOT-SEP Christophe - Made width Help&Web - RSS - Google+