Bingmap integration in Angular 6 using angular-map package

醉酒当歌 提交于 2019-12-05 07:28:28

问题


i am trying to implement bingmap in angular 6 using "angular-map" npm packages for that i have refer also referred problem statement: not created "bingmaps" folder in node_modules

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';

error:

ERROR in ./node_modules/angular-maps/fesm5/angular-maps.js Module not found: Error: Can't resolve 'bingmaps' in 'D:\bingmap\bingmap\node_modules\angular-maps\fesm5' i 「wdm」: Failed to compile. ERROR in src/app/app.module.ts(1,23): error TS6053: File 'D:/bingmap/bingmap/src/app/node_modules/bingmaps/types/MicrosoftMaps/Microsoft.Maps.All.d.ts' not found.

also installed npm install --save @types/bingmaps


回答1:


I just tested both locally & on stackblitz and realized that there are some library dependencies you have to install in order to make angular-maps work. I received the same error as you but once I installed the libraries the error was gone.

Your package.json should contain these libraries:

"@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", 

so you need to install them

npm install --save angular-maps
npm install --save bingmaps
npm install --save @types/bingmaps
npm install --save async@2.5.0
npm install --save json-loader

I included font-awesome as external link in index.html:

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

On app.module.ts include this as well as on app.component.ts:

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

If you check also on stackblitz you can see on dependencies which extra libraries are used



来源:https://stackoverflow.com/questions/51987104/bingmap-integration-in-angular-6-using-angular-map-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!