Icon
Example
#include <array>
#include "xleaflet/xmap.hpp"
#include "xleaflet/xmarker.hpp"
#include "xleaflet/xicon.hpp"
using size_type = std::array<int, 2>;
std::array<double, 2> center({52.204793, 360.121558});
auto map = xlf::map::initialize();
map.center = center;
map.zoom = 10;
map.finalize();
auto icon = xlf::icon::initialize();
icon.icon_url = "https://leafletjs.com/examples/custom-icons/leaf-red.png";
icon.icon_size = size_type({38, 95});
icon.icon_anchor = size_type({22, 94});
icon.finalize();
auto marker = xlf::marker::initialize();
marker.location = center;
marker.icon = icon;
marker.rotation_angle = 0;
marker.rotation_origin = "22px 94px";
marker.finalize();
map.add_layer(marker);
map
Attributes
Attribute |
Type |
Default Value |
Doc |
|---|---|---|---|
icon_url |
|
“” |
url for icon image |
shadow_url |
|
“” |
url for icon shadow image |
icon_size |
|
{10, 10} |
size of the icon, in pixels |
shadow_size |
|
{10, 10} |
size of the icon shadow, in pixels |
icon_anchor |
|
{0, 0} |
anchor point for the icon |
shadow_anchor |
|
{0, 0} |
anchor point for the icon shadow |
popup_anchor |
|
{0, 0} |
anchor point for the popup |