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

autocomplete #366

Closed danil-z closed 11 years ago

danil-z commented 11 years ago

Hello. Thanks for such awesome gem. I'm wondering how to use it with autocomplete? i can't make correct reference to this map in autocomplete...

#new.html.slim
    = gmaps({ "map_options" => { "libraries" => ["places"] } })

how to make this right - autocomplete.bindTo('bounds', Gmaps.map) ?

#ride.js.coffee
initialize_gmaps_autocomplete_starting_address = ->
  input = document.getElementById("ride_s")
  autocomplete = new google.maps.places.Autocomplete(input)
  autocomplete.setTypes ["geocode"]
  autocomplete.bindTo('bounds', Gmaps.map)
jQuery ->
  initialize_gmaps_autocomplete_starting_address()
apneadiving commented 11 years ago

Hi,

depending on the version you use, the google map object can be retrieved through:

before v2:

from v2:

danil-z commented 11 years ago

thanks