【问题标题】:Ionic2/3 angular google maps TypeError: Object(...) is not a function at new FitBoundsServiceIonic2/3 angular google maps TypeError: Object(...) is not a function at new FitBoundsService
【发布时间】:2019-03-07 02:00:30
【问题描述】:

我正在尝试从主网站:https://angular-maps.com/guides/getting-started/ 实例化一个 angular-google-maps 示例,以对应用程序进行一些测试。

我使用他们的示例代码如下:

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 ERROR 错误:未捕获(承诺中):TypeError: Object(...) is not a function TypeError: Object(...) is not a function 在新的 FitBoundsService (fit-bounds.js: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) 在新的 FitBoundsService (fit-bounds.js: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) 在 c (polyfills.js:3) 在 Object.reject (polyfills.js:3) 在 OverlayPortal.NavControllerBase._fireError (nav-controller-base.js:223) 在 OverlayPortal.NavControllerBase._failed (nav-controller-base.js:216) 在 nav-controller-base.js:263 在 t.invoke (polyfills.js:3) 在 Object.onInvoke (core.js:4760) 在 t.invoke (polyfills.js:3) 在 r.run (polyfills.js:3) 在 polyfills.js:3

感谢您帮助我们寻找问题的根源。

【问题讨论】:

标签: android angular ionic2 ionic3


【解决方案1】:

我添加了以下命令npm install rxjs@6 rxjs-compat@6 --save,它对我来说很好。

【讨论】:

  • 嘿,这也为我解决了!我之前看到了错误。现在我可以看到地图了。非常感谢!!!
  • @SANAAbdoulAziz 你能解释一下吗,agm-map 到 rxjs 和 rxjs-compat 之间的联系是什么?
【解决方案2】:

这可能是 @agm/core & angular 的打包版本依赖问题。

尝试为您的项目降低 package.json 中的“@agm/core”版本(我使用的是 1.0.0-beta.2,而不是安装的 1.0.0-beta.5)。

他们引入了一项重大更改:feat(*): support angular 6

【讨论】:

    【解决方案3】:

    我在使用时解决了版本:1.0.0-beta.3

    package.json:

    "@agm/core": "~1.0.0-beta.3"
    

    【讨论】:

      猜你喜欢
      • 2014-01-26
      • 2020-06-29
      • 2019-02-13
      • 2021-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      • 2019-09-02
      相关资源
      最近更新 更多