Вопрос

I'm using gmaps4rails V2 and and I'm not able to retrieve the markers position.

I have my array of Markers:

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

I want to iterate over it and delete the marker out of my map bounds

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

This is my console output:

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

Am I missing something?

Это было полезно?

Решение

Markers created by the gem are proxy on which you can create some methods.

To access the google object do:

 this.getServiceObject()

Then:

 this.getServiceObject().getPosition() // mind the parenthesis!
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top