apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

createServiceMarkersFromMarkers error when markers=[] #85

Closed iRonin closed 13 years ago

iRonin commented 13 years ago

Gmaps4Rails.createServiceMarkersFromMarkers throws an error when markers=[]. Simple if check should solve the issue, eg:

create_markers : ->
    @createServiceMarkersFromMarkers() if @markers.length > 0
    @clusterize()
apneadiving commented 13 years ago

Really? The loop is failing???

iRonin commented 13 years ago
Uncaught TypeError: Cannot read property 'lat' of undefined
Gmaps4Rails.Gmaps4Rails.createServiceMarkersFromMarkers
apneadiving commented 13 years ago

I'm disappointed the 'for' loop from coffeescript doesn't handle this. I'll fix that but it could be necessary in many places...

iRonin commented 13 years ago

Perhaps it's only the case for ranges? I would also think for loop should handle this.

apneadiving commented 13 years ago

ok, got it, my code was not that clean, will replace with:

for marker, index in markers

That will fix. Anything else to add to the new version? :)

iRonin commented 13 years ago

Not at the moment ;)