Blog

All Blog Posts  |  Next Post  |  Previous Post

Offline maps in TMS FNC Maps for Delphi

Bookmarks: 

Tuesday, February 21, 2023

In cases where an internet connection is not available it can be useful to still have a mapping application at hand.
This feature is available now for TTMSFNCOpenLayers in TMS FNC Maps.

There are 3 prerequisites to enable offline maps use:

  1. Local map tiles
  2. Local tile server
  3. Local OpenLayers API library


There are different sources available for both map tiles and tile servers. In this example we're going to use MapTiler for both.


Local map tiles

Map tiles contain the data needed to display the map. In this example we will use the sample map tiles included with MapTiler Server. Other map tiles are available from MapTiler Data as mbtiles files.


Local tile server

A tile server is needed to provide the correct map tiles that get requested by the map service. In this example we will use MapTiler Server.
Steps to configure MapTiler Server:

  • Download and install MapTiler Server
    During installation, make sure to note the port number for the server to run on and set the password you want to use.

  • Login to the MapTiler Server admin page
    Point your browser to the server admin page at "http://localhost:3650/admin" (replace the port number if you selected a different one during install) and enter the password to login.

    TMS Software Delphi  Components

  • Add the mbtiles file containing the map tiles
    Go to the "Tiles" tab. Click the "new tiles" button to add an mbtiles file, or use the sample data that is available by default.
    In this example we're going to use the sample data.

    TMS Software Delphi  Components

  • Get the tile server URL
    Go to the "Maps" tab. Here you can select the style that is used to display the map. There are a number of different map styles available by default. In this example we're going to use the Basic style so select the "Basic" item.

    TMS Software Delphi  Components

    There are a number of different URL types available. For the TTMSFNCOpenLayers TileServer URL you can use the XYZ URL. The XYZ URL is displayed in the "Map service (raster tiles)" topic.

    TMS Software Delphi  Components



Local OpenLayers API library

To configure TTMSFNCOpenLayers for offline use:

  • Set LibraryLocation to llOffline
    This will automatically generate a copy of the OpenLayers API JavaScript library in a temporary folder and use that to display the map.

  • Set a local TileServer URL
    Enter the XYZ URL retrieved from the MapTiler Server admin page here.

Example

 TMSFNCOpenLayers1.LibraryLocation := llOffline;
 TMSFNCOpenLayers1.Options.TileServer := 'http://localhost:3650/api/maps/basic/{z}/{x}/{y}.png';


TMS Software Delphi  Components


Available Now

The TMS FNC Maps update is available now for Delphi & Visual Studio Code (with TMS WEB Core). You can download the latest version and start using the new features right away!



Bart Holvoet


Bookmarks: 

This blog post has received 1 comment.


1. Wednesday, December 6, 2023 at 5:27:10 PM

I''m looking at options to replace an old Delphi app that uses a old component called TGlobe. The TGlobe component was actually good for what I required, but is unsupported. This is my first time using TMS FNC Open Layers and a maptiler offline server ... this example has been very much welcomed.
I''m really interested in from 25N to 65N and 0 to 80W (i.e. the North Atlantic oceanic crossings). Would I be better with just specific tiles rather than the full planet (maptiles-osm-2020-10-v3.11-planet.mbtiles) if I decide this is the right option?
I''d like Lat/Long graticule lines (1 degree for Lat, 10 degree for Long), is this possible via a property setting? Is changing the ocean colour possible?
Do you recommend some other tutorials to plot areas and also plot routes?

Stephen




Add a new comment

You will receive a confirmation mail with a link to validate your comment, please use a valid email address.
All fields are required.



All Blog Posts  |  Next Post  |  Previous Post