我刚刚在本地和 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] /cdn-cgi/l/email-protection
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';
如果您还检查堆栈闪电战 https://stackblitz.com/edit/angular-yvqvga您可以在依赖项上看到使用了哪些额外的库