Layers ControlΒΆ

The layers_control allows one to display a selector on the top right of the map in order to select which tile layer to display on the map.

#include "xleaflet/xmap.hpp"
#include "xleaflet/xbasemaps.hpp"
#include "xleaflet/xtile_layer.hpp"
#include "xleaflet/xwms_layer.hpp"
#include "xleaflet/xlayers_control.hpp"

auto map = xlf::map::initialize()
    .center({50, 354})
    .zoom(4)
    .finalize();

auto nasa_layer = xlf::basemap({"NASAGIBS", "ModisTerraTrueColorCR"}, "2018-03-30");
map.add_layer(nasa_layer);

auto wms = xlf::wms_layer::initialize()
    .url("https://demo.boundlessgeo.com/geoserver/ows?")
    .layers("nasa:bluemarble")
    .name("nasa:bluemarble")
    .finalize();
map.add_layer(wms);

map.add_control(xlf::layers_control());

map