灰烬这在组件的组件中未定义

时间:2018-09-26 08:21:51

标签: javascript google-maps ember.js

我正在使用Ember 2.18。

我有一个叫做map的组件,在这个组件中,我正在使用插件ember-cli-g-maps。对于这个组件,我传递了一个圆形数组。

这是模板:

        {{g-maps
        name='geo-push-map'
        lat=location.lat
        lng=location.lon
        zoom=mapConfig.zoom
        mapType=mapConfig.mapTypeId
        disableDefaultUI=mapConfig.disableDefaultUI
        showZoomControl=mapConfig.zoomControl
        showScaleControl=mapConfig.scaleControl
        circles=circles
        }}

这是我的圈子数组的外观:

circles: A([
  {
    id: 'my-circle',
    lat: 45,
    lng: 15,
    radius: 2000,
    click(event, circle) {},
    rightclick(event, circle) {},
    dblclick(event, circle) {},
    mouseover(event, circle) {},
    mouseout(event, circle) {},
    mouseup(event, circle) {},
    mousedown(event, circle) {},
    mousemove(event, circle) {},
    drag(e, circle) {},
    dragstart(e, circle) {},
    dragend(e, circle) {},
    radius_changed(circle) {},
    center_changed(circle) {},
    clickable: true,
    draggable: true,
    editable: true,
    fillColor: '#009dd4',
    fillOpacity: 0.3,
    strokeColor: '#005d7d',
    strokeOpacity: 0.3,
    strokePosition: google.maps.StrokePosition.CENTER,
    strokeWeight: 3,
    visible: true,
    zIndex: 999,
  },
]),

我现在希望能够在触发圆形事件时对地图组件内的属性进行突变。 我这样尝试过:

...
radius_changed(circle) {
 set(this, 'myRadius', circle.radius);
},
...

但是问题是,它告诉我this是不确定的。我怀疑这是因为它不在圈子范围内。有其他方法吗?当然,我阅读了该插件的文档以及相关问题,但是找不到解决方法。

1 个答案:

答案 0 :(得分:0)

我通过使用支持将动作传递到圈子事件ember-google-maps的其他插件解决了这个问题。