/MapTiles.jl

Primary LanguageJuliaOtherNOASSERTION

MapTiles

CI Coverage Status codecov.io

Installation

MapTiles.jl is not currently a Julia registered package.

Currently only developer version is available. It can be installed using:

$ julia
julia> ]
(@v1.5) pkg> dev https://github.com/yeesian/MapTiles.jl

Display map

Display map from buildin mapsource providers

using MapTiles
using Plots
provider = MapTiles.OpenStreetMapProvider()
minlon, minlat, maxlon, maxlat = -0.4, 46.2, 1.0, 46.9
minlon, minlat, maxlon, maxlat = -11.250, 40.984, 16.853, 52.483
basemap  = MapTiles.fetchmap(minlon, minlat, maxlon, maxlat, provider=provider)
plot(basemap)

It's possible to list all existing map providers using subtypes(MapTiles.AbstractProvider).

To get information about a specific map provider, you can use docstrings help using ?. It should show possible variants, terms of services...

julia> ?
help?> MapTiles.OpenStreetMapProvider

Display map from custom mapsource providers

A custom map source provider need to inherit abstract type AbstractProvider and implements geturl function for this custom map source.

Then, such a custom map provider can be used using:

using MapTiles
using MapTiles: AbstractProvider
import MapTiles: geturl
using Parameters
using Plots

@kwdef struct CustomMapProvider <: AbstractProvider
    maxtiles::Int = typemax(Int)
end

function geturl(provider::CustomMapProvider, x::Integer, y::Integer, z::Integer)
    "https://domain.com/$z/$y/$x.png"
end

provider = CustomMapProvider()
minlon, minlat, maxlon, maxlat = -0.4, 46.2, 1.0, 46.9
basemap  = MapTiles.fetchmap(minlon, minlat, maxlon, maxlat, provider=provider)
plot(basemap)

Packages in other Languages

If you're coming from Python or R, you might be interested in the following packages instead: