xleaflet Logo
stable

Installation

  • Installation

Usage

  • Introduction
  • Basic usage
  • Generator classes
  • Special Events
  • XProperty Events

Api Reference

  • Map
  • Tile layer
  • Marker
  • Icon
  • Popup
    • Example
    • Attributes
  • WMS layer
  • Image overlay and Video overlay
  • Polygon
  • Rectangle
  • Circle
  • Circle Marker
  • Marker Cluster
  • Heatmap
  • Velocity
  • Layer Group
  • GeoJSON
  • Fullscreen Control
  • Layers Control
  • Split Map Control
  • Measure Control
  • Widget control
  • Draw Control

Developer Zone

  • Releasing xleaflet
xleaflet
  • Docs »
  • Popup
  • Edit on GitHub

Popup¶

Example¶

#include "xwidgets/xhtml.hpp"

#include "xleaflet/xmap.hpp"
#include "xleaflet/xbasemaps.hpp"
#include "xleaflet/xmarker.hpp"
#include "xleaflet/xpopup.hpp"

std::array<double, 2> center = {52.204793, 360.121558};

auto map = xlf::map::initialize()
    .center(center)
    .zoom(9)
    .close_popup_on_click(false)
    .finalize();
map.display();

auto marker = xlf::marker::initialize()
    .location({52.1, 359.9})
    .finalize();
map.add_layer(marker);

xw::html message1, message2;
message1.value = "Try clicking the marker!";
message2.value = "Hello <b>World</b>";
message2.placeholder = "Some HTML";
message2.description = "Some HTML";

// Popup with a given location on the map:
auto popup = xlf::popup::initialize()
    .location(center)
    .child(message1)
    .close_button(false)
    .auto_close(false)
    .close_on_escape_key(false)
    .finalize();
map.add_layer(popup);

// Popup associated to a layer
marker.popup = message2;

Attributes¶

Attribute

Type

Default Value

Doc

location

std::array<double, 2>

{0.0, 0.0}

child

xwidget

Content of the popup

max_width

int

300

Max width of the popup, in pixels

min_width

int

50

Min width of the popup, in pixels

max_height

int

If set, creates a scrollable container of the given height inside a popup if its content exceeds it

auto_pan

bool

true

Set it to false if you don’t want the map to do panning animation to fit the opened popup

auto_pan_padding

std::array<double, 2>

{5, 5}

keep_in_view

bool

false

Set it to true if you want to prevent users from panning the popup off of the screen while it is open

close_button

bool

true

Controls the presence of a close button in the popup

close_on_escape_key

bool

true

Set it to false if you want to override the default behavior of the ESC key for closing of the popup

class_name

std::string

“”

A custom CSS class name to assign to the popup

Next Previous

© Copyright 2018, Johan Mabille, Sylvain Corlay, Wolf Vollprecht and Martin Renou Revision fc0467b5.

Built with Sphinx using a theme provided by Read the Docs.