xleaflet

  • Based on ipyleaflet & leaflet.js

In [ ]:
#include "xleaflet/xmap.hpp"
#include "xleaflet/xtile_layer.hpp"
#include "xleaflet/xmarker.hpp"
#include "xleaflet/xmarker_cluster.hpp"

In [ ]:
auto map = xlf::map_generator()
    .center({50, 354})
    .zoom(5)
    .finalize();
map

In [ ]:
auto nasa_layer = xlf::tile_layer_generator()
    .url("https://map1.vis.earthdata.nasa.gov/wmts-webmerc/MODIS_Terra_CorrectedReflectance_TrueColor/default/2018-08-01/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg")
    .name("NASAGIBS.ModisTerraTrueColorCR")
    .attribution("Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (<a href=\"https://earthdata.nasa.gov\">ESDIS</a>) with funding provided by NASA/HQ.")
    .max_zoom(9)
    .opacity(0.6)
    .finalize();
map.add_layer(nasa_layer);

In [ ]:
auto marker1 = xlf::marker_generator()
    .location({50, 354})
    .finalize();
auto marker2 = xlf::marker_generator()
    .location({52, 356})
    .finalize();
auto marker3 = xlf::marker_generator()
    .location({48, 352})
    .finalize();
auto marker_cluster = xlf::marker_cluster_generator()
    .markers({marker1, marker2, marker3})
    .finalize();
map.add_layer(marker_cluster);

In [ ]:
std::cout << marker1.location()[0] << ", " << marker1.location()[1] << std::endl;

In [ ]:
#include "xleaflet/xvelocity.hpp"

auto vmap = xlf::map_generator()
    .center({37.58, 261.65})
    .zoom(5)
    .finalize();

auto base_layer = xlf::basemap({"CartoDB", "DarkMatter"});
vmap.add_layer(base_layer);

vmap

In [ ]:
#include "nlohmann/json.hpp"
#include <fstream>

std::ifstream file("/home/wolfv/Programs/xleaflet/notebooks/velocity_data.json");
nlohmann::json data;
file >> data;

auto velocity = xlf::velocity_generator()
    .data(data)
    .velocity_scale(0.01)
    .max_velocity(20)
    .display_options(R"({
        "velocityType": "Global Wind",
        "displayPosition": "bottomleft",
        "displayEmptyString": "No wind data"
    })")
    .finalize();

vmap.add_layer(velocity);

In [ ]: