google-maps-for-rails gem で現在地をジオコーディングして表示したい
見る:
= gmaps({ "map_options" => { "auto_adjust" => true } })
= form_tag geocode_geo_locations_path, :method => :get, :remote => true do
= text_field_tag 'address'
= submit_tag 'search'
私のコントローラーには次のものがあります:
def geocode
@location = Gmaps4rails.geocode(params[:address])
if @location
@location_hash = @location.map { |loc| {:longitude => loc[:lng], :latitude => loc[:lat], :address => loc[:matched_address]} }.first
end
end
およびビュー geocode.js.erb で
Gmaps4Rails.replace_markers(<%=raw @location_hash.to_json %>);
これまでのところ、マップ上にマーカーが表示されますが、マップは auto_adjusted を取得しません。どうすればそれを達成できますか??