首页 > 解决方案 > 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();
  });

标签: angulareventsionic3leafletdraggable

解决方案


推荐阅读