我想要将 leaflet 插件 leaflet-mapwithlabels 导入到我的角度项目中。该库没有 NPM 安装选项,按照一些指南,我尝试直接添加 JS 文件...
我想将 leaflet 插件 leaflet-mapwithlabels 到我的 angular 项目中。该库没有 NPM 安装选项,按照一些指南,我尝试将 JS 文件直接添加到其自己的文件夹中的 node-modules 中,然后将其导入到我的组件中:
import * as L from 'leaflet';
import {GeoJSON} from "leaflet";
import "node_modules/leaflet-mapwithlabels/dist/leaflet-mapwithlabels.js"
并将其添加到我的 angular.json 中:
"styles": [
"@angular/material/prebuilt-themes/azure-blue.css",
"./node_modules/leaflet/dist/leaflet.css",
"./node_modules/leaflet-mapwithlabels/dist/leaflet-mapwithlabels.css",
"src/styles.scss"
],
"scripts": [
"./node_modules/leaflet/dist/leaflet.js",
"./node_modules/leaflet-mapwithlabels/dist/leaflet-mapwithlabels.js"
]
并在这里调用它:
private map!: L.MapWithLabels;
但那没用。那么我该如何添加它呢?
相关信息:
软件包.json:
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.1",
"@angular/cli": "^18.2.1",
"@angular/compiler-cli": "^18.2.1",
"@types/jasmine": "~5.1.4",
"@types/leaflet": "^1.9.12",
...
"dependencies": {
...
"@bluehalo/ngx-leaflet": "^18.0.2",
"@ngageoint/geopackage": "^4.2.6",
"@stijn98s/leaflet.tilelayer.pouchdbcached": "^1.0.0",
"@types/leaflet.fullscreen": "^3.0.2",
"leaflet": "^1.9.4",
"leaflet-geometryutil": "^0.10.3",
"leaflet.fullscreen": "^3.0.2",