【问题标题】:moving marker does not exist on type of import导入类型上不存在移动标记
【发布时间】:2021-01-19 07:04:41
【问题描述】:

导入类型不存在移动标记,请帮助我解决此错误。 我已经安装了 npm 包 npm install --save Leaflet-moving-marker 但它显示了错误 导入类型不存在移动标记

 // moving marker does not exist on type of import
    import * as L from 'leaflet';
    .....
    var map = L.map('map').setView([51.505, -0.09], 13);

    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
       attribution: '&copy; <a 
    href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> 
     contributors'
     }).addTo(map);

     L.marker([51.5, -0.09]).addTo(map)
    .bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
    .openPopup();
    var marker = marker.movingMarker([37.809185, -122.477351], {
         destinations: [
                {
                    latLng: [37.825766, -122.479218],
                    duration: 2000,
                },
                {
                    latLng: [37.831420, -122.479936],
                    duration: 3000
                },
                {
                    latLng: [37.832200, -122.480644],
                    duration: 1000
                }
            ],
          });
          marker.addTo(map);

【问题讨论】:

    标签: angular leaflet node-modules openstreetmap marker


    【解决方案1】:

    目前您只下载了movingMarker,但尚未将其添加到脚本中。

    要将其添加到脚本调用中:

    import 'leaflet-moving-marker';
    

    【讨论】:

    • 无法导入该文件在'leaflet-moving-marker'的index.ts文件中显示错误;
    • 您遇到什么错误?导入传单后是否添加了导入行?有leaflet-moving-marker typescript 定义还是您自己创建它们?
    • 错误:./node_modules/leaflet-moving-marker/index.ts 模块构建失败(来自 ./node_modules/@ngtools/webpack/src/index.js):错误:C:\Users TypeScript 编译中缺少 \RAJATSINGLA\Desktop\Air-Pollution\leaflet\node_modules\leaflet-moving-marker\index.ts。请通过 'files' 或 'include' 属性确保它在您的 tsconfig 中。丢失的文件似乎是第三方库的一部分。已发布库中的 TS 文件通常是库打包不良的标志。
    • 请在库存储库中打开一个问题以提醒其作者并要求他们使用 AngularCompilerPlugin.getCompiledFile 中的 Angular 包格式打包库
    • 这是上面 2 cmets 中显示的错误副本
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 2023-03-09
    • 2017-07-16
    • 1970-01-01
    • 2020-09-15
    • 1970-01-01
    相关资源
    最近更新 更多