我正在使用 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 数组的样子:
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
是未定义的。我怀疑是因为它不存在于圆圈的范围内。有没有不同的方法来做到这一点?当然,我阅读了插件的文档以及问题,但找不到办法。
我通过使用不同的插件解决了这个问题,该插件支持将动作传递给圈子事件ember-google-maps。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句