gmaps4rails V2无法检索标记位置

问题描述:

我正在使用gmaps4rails V2,而且我无法检索标记位置。gmaps4rails V2无法检索标记位置

我有我的标记的数组:

markers = handler.addMarkers(<%=raw @hash.to_json %>); 

我想遍历并删除标记出我的地图范围的

$.each markers, ->  
    pos = this.getPosition 
    if !bounds.contains pos 
    handler.removeMarker this 

这是我的控制台输出:

Uncaught TypeError: Object #<Marker> has no method 'getPosition' 

我错过了什么吗?

+0

什么'handler.addMarkers()'做什么?看起来'标记'根本不是标记。 –

宝石创建的标记是您可以在其上创建某些方法的代理。

要访问谷歌的对象做:

this.getServiceObject() 

然后:

this.getServiceObject().getPosition() // mind the parenthesis!