In [ ]:
#include "xwidgets/xbutton.hpp"
#include "xwidgets/xhtml.hpp"
#include "xleaflet/xmap.hpp"
#include "xleaflet/xbasemaps.hpp"
#include "xleaflet/xmarker.hpp"
#include "xleaflet/xpopup.hpp"
In [ ]:
std::array<double, 2> center = {52.204793, 360.121558};
auto map = xlf::map_generator()
.center(center)
.zoom(9)
.close_popup_on_click(false)
.finalize();
map.display();
auto marker = xlf::marker_generator()
.location({52.1, 359.9})
.finalize();
map.add_layer(marker);
In [ ]:
auto hidden_layer = xlf::basemap({"Esri", "WorldStreetMap"});
hidden_layer.visible = false;
map.add_layer(hidden_layer);
In [ ]:
void layer_visibility()
{
hidden_layer.visible = !hidden_layer.visible;
}
xw::button button;
button.description = "Click me!";
button.button_style = "success";
button.on_click(layer_visibility);
xw::html html;
html.value = "Hello <b>World</b>";
html.placeholder = "Some HTML";
html.description = "Some HTML";
In [ ]:
auto popup = xlf::popup_generator()
.location(center)
.child(button)
.close_button(false)
.auto_close(false)
.close_on_escape_key(false)
.finalize();
map.add_layer(popup);
In [ ]:
marker.popup = html;