Rover.Tiles (Rover v0.2.0)

Copy Markdown View Source

Named basemaps, and the escape hatch to any XYZ tile server.

Pass one to Rover.Components.map/1:

<.map id="m" tiles={:carto_light} ... />
<.map id="m" tiles={{:xyz, "https://tiles.example.com/{z}/{x}/{y}.png"}} ... />
<.map id="m" tiles={{:xyz, url, attributions: "© Example", max_zoom: 18}} ... />

Every preset carries the attribution its provider requires, and Rover renders it in the map's attribution control. Removing it is usually a licence violation — OpenStreetMap tiles in particular are free, but not unconditional. Both OSM and Carto presets point at public demo servers with usage policies that forbid heavy traffic; for anything beyond development, point {:xyz, …} at tiles you are entitled to use.

France

:ign_plan and :ign_ortho serve the French Géoportail — the reference plan and the aerial orthophotography, both open data and both intended for production use, which is what sets them apart from the demo endpoints above. :ign_ortho over a field is a different conversation with a grower than a road map is.

<.map id="parcels" tiles={:ign_ortho} shapes={@parcels} />

Summary

Functions

The list of available preset names.

Resolves a tile specification into the map handed to the JavaScript runtime.

Types

preset()

@type preset() ::
  :osm
  | :osm_hot
  | :carto_light
  | :carto_dark
  | :carto_voyager
  | :opentopomap
  | :esri_world_imagery
  | :ign_plan
  | :ign_ortho

t()

@type t() :: preset() | :none | {:xyz, String.t()} | {:xyz, String.t(), keyword()}

Functions

presets()

@spec presets() :: [preset()]

The list of available preset names.

Examples

iex> :carto_dark in Rover.Tiles.presets()
true

resolve!(name)

@spec resolve!(t()) :: map() | nil

Resolves a tile specification into the map handed to the JavaScript runtime.

Returns nil for :none, which renders a map with no basemap at all — useful when you only want the vector layers, or supply your own background.

Examples

iex> Rover.Tiles.resolve!(:osm).max_zoom
19

iex> Rover.Tiles.resolve!({:xyz, "https://x/{z}/{x}/{y}.png", attributions: "© Me"})
%{attributions: "© Me", max_zoom: 19, url: "https://x/{z}/{x}/{y}.png"}

iex> Rover.Tiles.resolve!(:none)
nil