Draw Control

The draw_control allows one to draw shapes on the map such as rectangle circle or lines.

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

auto water_color = xlf::basemap({"Stamen", "Watercolor"});

auto map = xlf::map::initialize();
map.layers = xlf::map::layer_list_type{water_color};
map.center = xlf::map::point_type{50, 354};
map.zoom = 5;
map.finalize();

    xeus::xjson polyline_options = {
    {"shapeOptions", {
        {"color", "#6bc2e5"},
        {"weight", 8},
        {"opacity", 1.0}
    }}
};

// Set some options for draw control
xeus::xjson polygon_options = {
    {"shapeOptions", {
        {"fillColor", "#6be5c3"},
        {"color", "#6be5c3"},
        {"fillOpacity", 1.0}
    }},
    {"drawError", {
        {"color", "#dd253b"},
        {"message", "Oups!"}
    }},
    {"allowIntersection", false}
};

xeus::xjson circle_options = {
    {"shapeOptions", {
        {"fillColor", "#efed69"},
        {"fillOpacity", 1.0},
        {"color", "#efed69"}
    }}
};

xeus::xjson rectangle_options = {
    {"shapeOptions", {
        {"fillColor", "#fca45d"},
        {"fillOpacity", 1.0},
        {"color", "#fca45d"}
    }}
};

auto draw_control = xlf::draw_control::initialize();
draw_control.polyline = polyline_options;
draw_control.polygon = polygon_options;
draw_control.circle = circle_options;
draw_control.rectangle = rectangle_options;
draw_control.finalize();
map.add_control(draw_control);

map