使用angular-map包在Angular 6中进行Bingmap集成

问题描述 投票:1回答:1

我试图使用“angular-map”npm包在角度6中实现bingmap,因为我有refer还有referred问题声明:未在node_modules中创建“bingmaps”文件夹

app.module.ts

/// <reference path="node_modules/bingmaps/types/MicrosoftMaps/Microsoft.Maps.All.d.ts" />
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { MapModule, MapAPILoader, BingMapAPILoaderConfig, BingMapAPILoader, WindowRef, DocumentRef, MapServiceFactory, BingMapServiceFactory } from "angular-maps";
import { AppComponent } from './app.component';

错误:

./node_modules/angular-maps/fesm5/angular-maps.js中的错误找不到模块:错误:无法解析'D:\ bingmap \ bingmap \ node_modules \ angular-maps \ fesm5'i“wdm中的'bingmaps' “:编译失败。 src / app / app.module.ts(1,23)中的错误:错误TS6053:文件'D:/bingmap/bingmap/src/app/node_modules/bingmaps/types/MicrosoftMaps/Microsoft.Maps.All.d.ts ' 未找到。

还安装了npm install --save @types/bingmaps

angular typescript bing-maps
1个回答
4
投票

我刚刚在本地和stackblitz上进行了测试,并意识到你必须安装一些库依赖项才能使角度图工作。我收到了与您相同的错误,但是一旦我安装了库,错误就消失了。

你的package.json应该包含这些库:

"@types/bingmaps": "0.0.1",
"angular-maps": "^6.0.1",
"async": "^2.5.0",
"bingmaps": "^2.0.3",
"core-js": "^2.5.4",
"font-awesome": "^4.6.3",
"json-loader": "^0.5.7", 

所以你需要安装它们

npm install --save angular-maps
npm install --save bingmaps
npm install --save @types/bingmaps
npm install --save [email protected]
npm install --save json-loader

我在index.html中包含了font-awesome作为外部链接:

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />

在app.module.ts包括此以及app.component.ts:

import {
    MapModule,
    MapAPILoader,
    MarkerTypeId,
    IMapOptions,
    IBox,
    IMarkerIconInfo,
    WindowRef,
    DocumentRef,
    MapServiceFactory,
    BingMapAPILoaderConfig,
    BingMapAPILoader,
    GoogleMapAPILoader,
    GoogleMapAPILoaderConfig
} from 'angular-maps';

如果你也查看stackblitz,你可以看到依赖项使用了哪些额外的库

© www.soinside.com 2019 - 2024. All rights reserved.