我目前无法集成BeautifyMarker插件与ngx-leaflet角2软件包。
我一直跟随着BeautifyMarker安装说明和ngx-传单插件说明一起走,没有运气。
我用npm install来抓取BeautifyMarker,字体太棒了,并且已经安装了引导带。根据ngx-leaflet官方教程,传单也已被适当添加和配置。
我编辑了我的angular-cli.json文件以包含BeautyMarker .css和.js文件,如下所示:
"styles": [
"styles.css",
"../node_modules/leaflet/dist/leaflet.css",
"../node_modules/font-awesome/css/font-awesome.css",
"../node_modules/bootstrap/dist/css/bootstrap.css",
"../node_modules/beautifymarker/leaflet-beautify-marker-icon.css"
],
"scripts": [
"../node_modules/leaflet/dist/leaflet.js",
"../node_modules/beautifymarker/leaflet-beautify-marker-icon.js",
], ...我还完全导入了包,因为它扩展了L,如下所示:
import * as L from 'leaflet';
import 'beautifymarker';那不管用,所以我也试了一下:
import * as L from 'leaflet';
import '../../node_modules/beautifymarker/leaflet-beautify-marker-icon.js';还试着完全省略导入,一个la的heatmap.js插件。所有这些都不允许我访问L.BeautifyIcon。
有小费吗?
发布于 2018-08-06 08:51:41
我花了些时间调查你的问题。
我所做的是:
angular.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"
]app.module.ts
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
..
imports: [
..,
LeafletModule.forRoot()
],app.component.ts
// 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>https://stackoverflow.com/questions/51679056
复制相似问题