【问题标题】:Error creating Circle object in ionic 3在 ionic 3 中创建 Circle 对象时出错
【发布时间】:2018-05-04 00:00:51
【问题描述】:

我正在使用 Google Maps API。我要在哪里创建一个围绕市场创建的圈子。我执行它(正常工作)

    createCircle(loc: LatLng){

    return  this.map.addCircle(
      {'center': loc,
      'radius': 300,
      'strokeColor' : '#AA00FF',
      'strokeWidth': 5,
      'fillColor' : '#880000'}

    );

}

当我尝试创建 Circle 变量时出现我的错误

circle:Circle;

我尝试改变方法

         createCircle(loc: LatLng){

 this.circle =   this.map.addCircle(
      {'center': loc,
      'radius': 300,
      'strokeColor' : '#AA00FF',
      'strokeWidth': 5,
      'fillColor' : '#880000'}

    );

    return this.circle;
}

我看到了这个错误。

我的错误是什么?非常感谢。

【问题讨论】:

  • 请用 100% 英语编辑您的问题
  • 很难看到代码中ContactPage 的其余部分。你最好只实例化圆圈,例如:circle: createCircle(),而不是你所做的。但是,如果您可以提供一些示例代码来显示问题所在,那么可以给出更好的答案。

标签: angular google-maps variables ionic-framework ionic3


【解决方案1】:

我用

circle:Circle;

编辑方法

createCircle(loc: LatLng){

    this.map.addCircle({
      'center': loc,
      'radius': this.radius,
      'strokeColor': '#AA00FF',
      'strokeWidth': 5,
      'fillColor': '#880000'
    }).then((circle: Circle) => {
      this.circle = circle;
    })

    return this.circle;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-27
    • 2016-06-16
    • 2020-12-24
    • 1970-01-01
    • 1970-01-01
    • 2015-01-20
    • 2020-07-31
    相关资源
    最近更新 更多