angular - Leaflet map draggable - 如何在拖动事件中调用函数或更改类变量
问题描述
我有一个显示地图的程序。如果你拖动地图,一个类变量应该改变,或者我想在地图被拖动后调用一个方法来做某事。
我使用带有角度(ts)的inonic3并具有以下代码:
loadmap() {
// Define and add Leaflet Map with OSM TileLayer
this.map = leaflet.map("map");
leaflet.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attributions: 'OpenStreetMap',
}).addTo(this.map);
this.map.setZoom(25);
this.map.setView([0,0])
console.log('MapLoadSuccsess');
this.map.on("dragend", function(e) {
this.loconoff = false;
console.log("post Drag: " + this.loconoff);
dosomething();
});
解决方案
推荐阅读
- python - 如何有效地从字符串中提取子字符串(带 - 或 _)
- linux - 哪个进程发送 SIGKILL 并终止我的 Namecheap 服务器上的所有 SSH 连接?
- javascript - 在Javascript中的if块中动态放置条件
- java - 使用 android studio java Recycler 视图从 Firebase 实时数据库中删除节点
- c# - MediatR 定制行为管道
- java - 多变量函数的数值微分
- c++ - 构造实例的最佳实践
- javascript - 将 prop 从中间组件传递到 props.children
- c++ - 如何使用 gdb 在 vscode 中查看结构的非漂亮版本?
- javascript - 如何访问此 javascript 对象以进行动态 src 更新(plyr html5