小编Une*_*ess的帖子

在Leaflet弹出窗口中添加按钮

当我尝试在Leaflet弹出窗口中添加按钮时出现问题.单击地图时会生成弹出窗口.

理想情况下,我想popo显示2个按钮:

  • 从这里开始
  • 并前往这个位置

这个草图是我想要的结果的一个例子:

 ________________________________________________
|You clicked the map at LatLng(XXXXX,XXXXX)      |
|  ---------------    -------------------        |
| |Start from here|  |Go to this location|       |
|  ---------------    -------------------        |
|___________________  ___________________________|
                   \/
Run Code Online (Sandbox Code Playgroud)

这就是我在popUp中的内容:你在LatLng点击了地图(XXXXX,XXXX)[object HTMLButtonElement]

我正在尝试使用L.domUtil创建按钮

defineYourWaypointOnClick(e: any) {

var choicePopUp = L.popup();
var container = L.DomUtil.create('div'),
  startBtn = this.createButton('Start from this location', container),
  destBtn = this.createButton('Go to this location', container);

choicePopUp
  .setLatLng(e.latlng)
  .setContent('You clicked the map at ' + e.latlng.toString() + '<br>' + startBtn)
  .openOn(this.map);

L.DomEvent.on(startBtn, 'click', () => …
Run Code Online (Sandbox Code Playgroud)

javascript leaflet typescript angular

6
推荐指数
1
解决办法
5405
查看次数

标签 统计

angular ×1

javascript ×1

leaflet ×1

typescript ×1