8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

如何将非类型化的 Leaflet 插件导入 Angular 项目?

vinuZachariah 2月前

14 0

我想要将 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",
帖子版权声明 1、本帖标题:如何将非类型化的 Leaflet 插件导入 Angular 项目?
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由vinuZachariah在本站《javascript》版块原创发布, 转载请注明出处!
最新回复 (0)
返回
作者最近主题: