C++ backend for the jupyter-leaflet map visualization library

In [1]:
#include <iostream>
#include <string>
#include <fstream>

#include "xleaflet/xmap.hpp"
#include "xleaflet/xbasemaps.hpp"
#include "xleaflet/xgeo_json.hpp"

In [2]:
auto black_and_white = xlf::basemap({"OpenStreetMap", "BlackAndWhite"});

auto map = xlf::map_generator()
    .layers({black_and_white})
    .center({34.6252978589571, -77.34580993652344})
    .zoom(10)
    .finalize();

map


Out[2]:

 Load a local json file


In [3]:
std::ifstream file("data/geo.json");
xeus::xjson geo_data;
file >> geo_data;

In [4]:
for (auto& feature: geo_data["features"])
{
    feature["properties"]["style"] = {
        {"weight", 1},
        {"fillOpacity", 0.5}
    };
}

In [5]:
void print_event_callback(xeus::xjson event)
{
    std::cout << event.dump(4);
}

In [6]:
auto geo_json = xlf::geo_json_generator()
    .data(geo_data)
    .finalize();
// geo_json.on_hover(print_event_callback);
// geo_json.on_click(print_event_callback);
map.add_layer(geo_json);

In [ ]: