Map¶
Example¶
#include "xleaflet/xmap.hpp"
#include "xleaflet/xbasemaps.hpp"
auto map = xlf::map::initialize()
.layers({xlf::basemap({"NASAGIBS", "ModisTerraTrueColorCR"}, "2017-04-08")})
.center({52.204793, 360.121558})
.zoom(4)
.finalize();
map
Attributes¶
Attribute |
Type |
Default Value |
Doc |
---|---|---|---|
layers |
|
{default_layer} |
Vector of layers |
controls |
|
{} |
Vector of controls |
center |
|
{0.0, 0.0} |
Initial geographic center of the map |
zoom |
|
12 |
Initial map zoom level |
max_zoom |
|
18 |
|
min_zoom |
|
1 |
|
dragging |
|
true |
Whether the map be draggable with mouse/touch or not |
touch_zoom |
|
true |
Whether the map can be zoomed by touch-dragging with two fingers on mobile |
scroll_wheel_zoom |
|
false |
Whether the map can be zoomed by using the mouse wheel |
double_click_zoom |
|
true |
Whether the map can be zoomed in by double clicking on it and zoomed out by double clicking while holding shift |
box_zoom |
|
true |
Whether the map can be zoomed to a rectangular area specified by dragging the mouse while pressing the shift key |
tap |
|
true |
Enables mobile hacks for supporting instant taps |
tap_tolerance |
|
15 |
The max number of pixels a user can shift his finger during touch for it to be considered a valid tap |
world_copy_jump |
|
false |
With this option enabled, the map tracks when you pan to another “copy” of the world and seamlessly jumps to |
close_popup_on_click |
|
true |
Set it to false if you don’t want popups to close when user clicks the map |
bounce_at_zoom_limits |
|
true |
Set it to false if you don’t want the map to zoom beyond min/max zoom and then bounce back when pinch-zooming |
keyboard |
|
true |
Makes the map focusable and allows users to navigate the map with keyboard arrows and +/- keys |
keyboard_pan_offset |
|
80 |
|
keyboard_zoom_offset |
|
1 |
|
inertia |
|
true |
If enabled, panning of the map will have an inertia effect |
inertia_deceleration |
|
3000 |
The rate with which the inertial movement slows down, in pixels/second² |
inertia_max_speed |
|
1500 |
Max speed of the inertial movement, in pixels/second |
zoom_control |
|
true |
|
attribution_control |
|
true |
|
zoom_animation_threshold |
|
4 |
Methods¶
Method |
Return type |
Arguments |
Doc |
---|---|---|---|
add_layer |
|
|
Add a new layer to the map |
remove_layer |
|
|
Remove a layer from the map |
clear_layers |
|
Remove all layers from the map |
|
add_control |
|
|
Add a new control to the map |
remove_control |
|
|
Remove a control from the map |
clear_controls |
|
Remove all controls from the map |
|
on_interaction |
|
|
Add a callback on interaction |