我试图实例化一个角度-谷歌地图的例子,从主要网站:https://angular-maps.com/guides/getting-started/,以进行一些测试的应用。
我使用它们的示例代码如下:
import { Component } from '@angular/core';
@Component({
selector: 'page-location',
templateUrl: 'location.html',
})
export class LocationPage {
title: string = 'My first AGM project';
lat: number = 51.678418;
lng: number = 7.809007;
}
page-location
{
agm-map {
height: 150px;
}
}
<h1>{{ title }}</h1>
<!-- this creates a google map on the page with the given lat/lng from -->
<!-- the component as the initial center of the map: -->
<agm-map style="height: 300px;" [latitude]="lat" [longitude]="lng">
<agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
</agm-map>
最后抛出以下错误:
core.js:1449错误:未知(承诺):TypeError: Object(.)不是函数TypeError: Object(.)不是新FitBoundsService的功能(fit-界is :31)在createClass (core.js:12481)、_createProviderInstance (core.js:12458)、createProviderInstance (core.js:12299)、createViewNodes (core.js:13771)、callViewAction (core.js:14218)、execComponentViewsAction (core.js:14127)、createViewNodes (core.js:13812)和createRootView (core.js:13673)。callWithDebugContext (core.js:15098) at new FitBoundsService (fit-界31:31) at createClass (core.js:12481) at _createProviderInstance (core.js:12458) at createProviderInstance (core.js:12299) at createViewNodes (core.js:13771) at callViewAction (core.js:14218) at execComponentViewsAction (core.js:14127) at createViewNodes (core.js:13812) at createViewNodes(core.js:13812)callWithDebugContext (core.js:15098) at c (polyfills.js:3) at Object.reject (polyfills.js:3) at OverlayPortal.NavControllerBase._fireError (nav-控制器-base.js:223) at OverlayPortal.NavControllerBase._failed (nav-控制器-base.js:216) at nav-控制器-base.js:263 at t.invoke (polyfills.js:3) at Object.onInvoke (core.js:4760 ))在t.invoke ( polyfills.js:3 ) at r.run (polyfills.js:3) at polyfills.js:3 我希望你能帮忙找出这个问题的根源。
发布于 2018-11-06 17:24:38
我添加了以下命令npm install rxjs@6 rxjs-compat@6 --save
,它对我很好。
发布于 2018-10-04 01:45:14
这可能是一个与@agm/core & issue有关的打包版本依赖问题。
尝试降低项目package.json中的"@agm/core“版本(我使用的是1.0.0-beta.2,而不是已安装的1.0.0-beta.5)。
他们引入了一个突破性的变化:):支撑角6
发布于 2018-12-18 04:08:21
在使用版本时已解决: 1.0.0-beta.3
package.json:
"@agm/core": "~1.0.0-beta.3"
https://stackoverflow.com/questions/52599926
复制相似问题