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.
Carto API keys
Carto's basemaps now need an API key. Without one the tiles still load — they
arrive with API KEY REQUIRED stamped diagonally across every one, so the
symptom is a legible map wearing a watermark rather than a blank map or an
error in the console. That is worth knowing before you go looking for a 401
that never comes.
The key is free: Carto issue it by return email, with no approval queue and no Carto account, and it covers 5 million tile requests a month across their raster and vector services. Their terms require the CARTO and OpenStreetMap attribution to stay visible, which Rover renders for you. Request one at https://carto.com/basemaps/apikey/.
Configure a default for the whole app:
config :rover, Rover.Tiles, carto_api_key: "YOUR_KEY"or pass one per call, which overrides the configured default:
<.map id="m" tiles={{:carto_dark, key: "YOUR_KEY"}} ... />Carto also say the raster (PNG) service is being retired in favour of vector
tiles, and that they are considering freezing its data updates — the
cartography would stay where it is while vector keeps moving. No date is
published for either. Rover's map renders basemaps through OpenLayers' raster
XYZ source today, so the presets here stay on raster until Rover grows a
vector tile layer; the key you request now covers both services, so nothing is
wasted when it does.
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
Functions
@spec presets() :: [preset()]
The list of available preset names.
Examples
iex> :carto_dark in Rover.Tiles.presets()
true
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