Tile layer¶
Example¶
#include "xleaflet/xmap.hpp"
#include "xleaflet/xbasemaps.hpp"
auto map = xlf::map::initialize()
.center({52.204793, 360.121558})
.zoom(9)
.finalize();
auto dark_matter_layer = xlf::basemap({"CartoDB", "DarkMatter"});
map.add_layer(dark_matter_layer);
map
Usage¶
Creating a tile_layer
is straightforward, a list of basic tile layers is provided.
This list of layers can be accessed using the basemaps
function:
#include <iostream>
#include "xleaflet/xbasemaps.hpp"
std::cout << xlf::basemaps().dump(6) << std::endl;
A tile_layer
instance can be created using the basemap
function, specifying the wanted map
(e.g. {"CartoDB", "DarkMatter"}
, {"Strava", "Winter"}
, {"NASAGIBS", "ModisTerraTrueColorCR"}
, …).
Sometimes one could want to specify the date of the given images, for instance with NASA images:
auto nasa_layer = xlf::basemap({"NASAGIBS", "ModisTerraTrueColorCR"}, "2018-04-08");
map.add_layer(nasa_layer);
Attributes¶
Attribute |
Type |
Default Value |
---|---|---|
url |
|
“https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png” |
min_zoom |
|
0 |
max_zoom |
|
18 |
tile_size |
|
256 |
attribution |
|
“Map data (c) <a href='https://openstreetmap.org'>OpenStreetMap</a> contributors” |
detect_retina |
|
false |
opacity |
|
1.0 |
visible |
|
true |