【发布时间】:2017-09-13 15:48:19
【问题描述】:
我需要一些关于导入的帮助,我正在使用定义类型的@types/leaflet
export namespace Icon {
interface DefaultIconOptions extends BaseIconOptions {
imagePath?: string;
}
class Default extends Icon<DefaultIconOptions> {
static imagePath?: string;
constructor(options?: DefaultIconOptions);
}
}
现在,我想使用以下扩展图标行为的 libreray:https://www.npmjs.com/package/leaflet-fa-markers 问题是它是纯 JS 并且类型未在 @types 中定义... node_modules/leaflet-fa-markers/L.Icon.FontAwesome.js
L.Icon.FontAwesome = L.Icon.extend({
options: {
popupAnchor: [0, -50]
},
createIcon: function () {
var div = document.createElement('div');
...
到目前为止,我已经在 .angular-cli.json 中导入了 js 和 css,但不知道如何在我的服务中导入它...到目前为止,我已经导入了 js lib
import 'leaflet-fa-markers';
//...
let marker = new L.Marker([ lat, lng], {
icon: L.icon.fontAwesome({
iconClasses: 'fa fa-info-circle', // you _could_ add other icon classes, not tested.
markerColor: '#00a9ce',
iconColor: '#FFF'
}),
draggable: true});
但我得到了错误:
src/app/_services/canimap.service.ts (99,24): Property 'fontAwesome' does not exist on type '(options: IconOptions) => Icon<IconOptions>'.
【问题讨论】:
标签: angular typescript types