【问题标题】:agm-circle Cannot read property 'then' of undefined at Observable.subscribeagm-circle 无法读取 Observable.subscribe 处未定义的属性“then”
【发布时间】:2020-12-31 13:59:35
【问题描述】:

下午好,我是 angular 8 和 AGM 地图的新手,我正在尝试在地图上生成一个圆圈,但是当我实现它时,我得到以下信息

ERROR TypeError: Cannot read property 'then' of undefined
    at Observable._subscribe (agm-core.js:292)
    at Observable._trySubscribe (Observable.js:42)
    at Observable.subscribe (Observable.js:28)
    at agm-core.js:1499
    at Map.forEach (<anonymous>)
    at AgmCircle._registerEventListeners (agm-core.js:1498)
    at AgmCircle.ngOnInit (agm-core.js:1449)
    at checkAndUpdateDirectiveInline (core.js:31910)
    at checkAndUpdateNodeInline (core.js:44367)
    at checkAndUpdateNode (core.js:44306)

我的代码如下

   <mat-card-content class="text-justify ">
     <agm-map [latitude]=" contri.latitude " [longitude]=" contri.longitude " [zoom]="mapzoom ">
          <agm-circle [latitude]="40.7127753"  [longitude]="-74.0059728"                     [clickable]="false"    [draggable]="true"   [editable]="false"   [fillColor]="green"                       [fillOpacity]="0"       [radius]="175.61"> </agm-circle>

                </agm-map>
            </mat-card-content>

在 app.module.js 我有以下导入

 imports: [ 
    AgmCoreModule.forRoot({
      apiKey: 'AIzZZaassdqws4aaa',
      libraries: ["places", "geometry"]
    })

有人收到此错误或知道是什么原因造成的

【问题讨论】:

  • 嘿@MRSDY SOTO,在这个问题上运气好吗?我也因此陷入困境。
  • 我也是,同样的错误。只有 [latitude],[longitude],[radius],[fillColor] 绑定在 html 上,并且它们必须是正确的,因为圆圈绘制正确。
  • 您可以在库本身中添加一些更改,我正在分享一个链接,您可以在其中找到要更改的内容:github.com/SebastianM/angular-google-maps/issues/1871我试过这个并且这个工作。

标签: angularjs angular-components agm


【解决方案1】:

临时解决方案是降级到 "@agm/core": "1.1.0"

这对我有用

实际版本是 3.0.0 beta 并且是 Pre Release,所以这意味着它不是一个稳定的版本

我从这个 plunker 中获取了示例 package.json https://stackblitz.com/edit/angular-google-maps-demo?file=app%2Fapp.component.html

查看版本 https://github.com/SebastianM/angular-google-maps/releases

【讨论】:

    猜你喜欢
    • 2021-01-04
    • 2017-04-21
    • 2018-12-23
    • 2019-08-19
    • 2016-10-23
    • 2014-09-07
    • 2015-09-08
    • 2018-01-12
    相关资源
    最近更新 更多