我花了点时间调查你的问题。
我所做的是:
-
已安装传单,@asymmetrik/ngx传单&@types/传单
-
安装了bootstrap,字体很棒,漂亮的marker&将它们添加到angular.json
-
重新启动服务器,因为监视程序仅用于src文件夹,而不观察angular-cli.json是否有更改,以使字体显示为awesome
角度.json
"styles": [
"node_modules/leaflet/dist/leaflet.css",
"node_modules/bootstrap/dist/css/bootstrap.css",
"node_modules/font-awesome/css/font-awesome.css",
"node_modules/beautifymarker/leaflet-beautify-marker-icon.css",
"src/styles.css"
],
"scripts": [
"node_modules/leaflet/dist/leaflet.js",
"node_modules/beautifymarker/leaflet-beautify-marker-icon.js"
]
应用模块.ts
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
..
imports: [
..,
LeafletModule.forRoot()
],
应用组件
// import * as L from 'leaflet';
// import 'beautifymarker';
// instead of the above try
import 'leaflet';
import 'beautifymarker';
declare let L;
options = {
layers: [
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18, attribution: '...' }
)
],
zoom: 12,
center: L.latLng(46.879966, -121.726909)
};
beautifyOptions = {
icon: 'plane',
borderColor: '#8D208B',
textColor: '#8D208B',
backgroundColor: 'transparent'
};
layers = [
L.marker([ 46.879966, -121.726909 ], {
icon: L.BeautifyIcon.icon(this.beautifyOptions)
})
];
模板
<div style="height: 500px;"
leaflet
[leafletOptions]="options"
[leafletLayers]="layers">
</div>
Demo