导入扩展类的模块

mne*_*ann 2 leaflet node-modules typescript angular

在寻找在Leaflet.js 中旋转标记的方法时,我找到了模块Leaflet-rotatedmarker。我是通过 npm 安装的,但现在我不知道如何实际使用它。

根据自述文件,它只扩展了现有的Marker类。据我了解,我现在应该可以调用Marker.setRotationAngle(),但该函数不存在。Marker从导入leaflet-rotatedmarker也不起作用。

如何正确导入扩展类或如何使用模块中的功能/属性扩展现有的传单类?谢谢。

我说的是import { XYZ } from 'leaflet-rotatedmarker'声明。

编辑:

如果我尝试rotationAngle在构造函数中设置它,它也不起作用:

const marker = L.marker([tmpAgv.Pos.X, tmpAgv.Pos.Y], { alt: tmpAgv.Id }, {rotationAngle: 180}).addTo(this.mapObject);
Run Code Online (Sandbox Code Playgroud)

标记仍未旋转。

Mai*_*jat 6

我安装了与您相同的软件包:

npm install leaflet-rotatedmarker
Run Code Online (Sandbox Code Playgroud)

并导入它:

import 'leaflet-rotatedmarker';
Run Code Online (Sandbox Code Playgroud)

这就是我使用的方式:

let m = L.marker([lat,lng]).addTo(this.map);
m.setRotationAngle(180);
Run Code Online (Sandbox Code Playgroud)

以及之前和之后的结果:

传单前

后:

传单之后