Skip to content

Tyler.jl

A package for downloading map tiles on demand from different data source providers.

This package is currently in the initial phase of development. It needs support. Sponsorships are welcome!

Installation

In the Julia REPL type:

julia
] add Tyler

The ] character starts the Julia package manager. Hit backspace key to return to Julia prompt.

Or, explicitly use Pkg

julia
using Pkg
Pkg.add(["Tyler.jl"])

Demo: London

julia
using Tyler, GLMakie
m = Tyler.Map(Rect2f(-0.0921, 51.5, 0.04, 0.025))

INFO

A Rect2f definition takes as input the origin, first two entries, and the width and hight, last two numbers.

Tile provider

We can use a different tile provider as well as any style theme from Makie as follows:

julia
using GLMakie, Tyler
using Tyler.TileProviders

provider = TileProviders.OpenStreetMap(:Mapnik)
london = Rect2f(-0.0921, 51.5, 0.04, 0.025)

with_theme(theme_dark()) do
    m = Tyler.Map(london; provider)
    hidedecorations!(m.axis)
    hidespines!(m.axis)
    m
end

Providers list

More providers are available. See the following list:

julia
providers = TileProviders.list_providers()
Dict{Function, Vector{Symbol}} with 40 entries:
  SafeCast           => []
  HikeBike           => [:HikeBike, :HillShading]
  AzureMaps          => [:MicrosoftImagery, :MicrosoftBaseDarkGrey, :MicrosoftB…
  GeoportailFrance   => [:plan, :parcels, :orthos]
  OpenFireMap        => []
  OpenSeaMap         => []
  Jawg               => [:Streets, :Terrain, :Lagoon, :Sunny, :Dark, :Light, :M…
  CyclOSM            => []
  USGS               => [:USTopo, :USImagery, :USImageryTopo]
  NASAGIBSTimeseries => [:Agricultural_Lands_Croplands_2000, :Agricultural_Land…
  Thunderforest      => [:OpenCycleMap, :Transport, :TransportDark, :SpinalMap,…
  Esri               => [:WorldStreetMap, :DeLorme, :WorldTopoMap, :WorldImager…
  MapBox             => []
  JusticeMap         => [:income, :americanIndian, :asian, :black, :hispanic, :…
  OpenTopoMap        => []
  NLS                => [:osgb63k1885, :osgb1888, :osgb10k1888, :osgb1919, :osg…
  MtbMap             => []
  Stadia             => [:AlidadeSmooth, :AlidadeSmoothDark, :OSMBright, :Outdo…
  OpenStreetMap      => [:Mapnik, :DE, :CH, :France, :HOT, :BZH]
  ⋮                  => ⋮

INFO

For some providers additional configuration steps are necessary, look at the TileProviders.jl documentation for more information.

Identifying your application

Tile servers use the User-Agent header of a request to tell their users apart, and several of them block traffic that does not identify itself - the OSM Tile Usage Policy is the best known example. Tyler therefore names itself and its version in every request it makes, e.g. Tyler.jl/0.2.6 (+https://github.com/MakieOrg/Tyler.jl).

If you build an application on top of Tyler, identify that application instead, ideally together with a way of contacting you:

julia
using Tyler
Tyler.USER_AGENT[] = "MyTownMaps/1.4 (+https://mytownmaps.example.com; maps@example.com)"

INFO

Set this before creating a Map, since downloaders read Tyler.USER_AGENT[] when they are created. A single downloader can also be identified separately, via the user_agent keyword of Tyler.ByteDownloader and Tyler.PathDownloader.

Figure size & aspect ratio

Although, the figure size can be controlled by passing additional arguments to Map, it's better to define a Figure first and then continue with a normal Makie's figure creation workflow, namely

julia
using GLMakie, Tyler
using Tyler.TileProviders

provider = TileProviders.OpenTopoMap()
london = Rect2f(-0.0921, 51.5, 0.04, 0.025)

with_theme(theme_dark()) do
    fig = Figure(; size =(1200,600))
    ax = Axis(fig[1,1]) # aspect = DataAspect()
    m = Tyler.Map(london; provider, figure=fig, axis=ax)
    wait(m)
    hidedecorations!(ax)
    hidespines!(ax)
    fig
end

Next, we could add any other plot type on top of the ax axis defined above.