[英]How to include Leaflet.TextPath or Leaflet.PolylineDecorator in Angular 6 CLI app?
I have been trying to include https://github.com/makinacorpus/Leaflet.TextPath in Angular 6 CLI application but with no success. 我一直试图在Angular 6 CLI应用程序中包含https://github.com/makinacorpus/Leaflet.TextPath ,但没有成功。 Can anyone please guide me?
谁能指导我? Thanks in advance.
提前致谢。
EDIT: Or if this one? 编辑:或者如果这吗? https://github.com/bbecquet/Leaflet.PolylineDecorator , it also has types.
https://github.com/bbecquet/Leaflet.PolylineDecorator ,它也有类型。
To be able to include Leaflet.TextPath you need to install Leaflet & Leaflet.TextPath in your angular-cli project and then import them as follows: 为了能够包含Leaflet.TextPath,您需要在angular-cli项目中安装Leaflet和Leaflet.TextPath,然后按如下所示导入它们:
in angular.json add: 在angular.json中添加:
"styles": [
"node_modules/leaflet/dist/leaflet.css",
"src/styles.css"
],
"scripts": [
"node_modules/leaflet/dist/leaflet.js"
]
in component.ts add: 在component.ts中添加:
...
import 'leaflet';
import 'leaflet-textpath';
declare let L; // to be able to use L namespace
...
Then you initialize your code inside ngOnInit and you place the code as indicated in the library: 然后,在ngOnInit中初始化代码,然后按照库中的指示放置代码:
ngOnInit() {
your code initialization here
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.