【发布时间】:2020-09-11 22:13:19
【问题描述】:
我安装了leaflet-area-select (https://github.com/w8r/leaflet-area-select) 插件,但是当我定义选择区域时出现以下错误
我启动了npm install --save leaflet-area-select
在我添加的 angular.json 中
"scripts": [
"node_modules/leaflet/dist/leaflet.js",
"node_modules/leaflet-area-select/dist/Map.SelectArea.min.js",
"node_modules/jquery/dist/jquery.min.js"
],
在代码中,我添加的说明如下:
import SelectArea from 'leaflet-area-select';
public map: L.map;
this.map = L.map('map', {
center: [37.606655, 15.1606003],
selectArea: true,
zoom: 10
});
this.map.on('areaselected', (e) => {
console.log(e.bounds.toBBoxString()); // lon, lat, lon, lat
});
this.map.selectArea.setCtrlKey(true);
似乎无法识别 SelectArea
如果我在行上移动鼠标, 'SelectArea' 已声明,但其值从未被读取出现
我该如何解决这个问题?
【问题讨论】: