私は本当にdisapointed、私は私のアプリでオートコンプリートを実装しようとしているが、私はそれを行う方法を知らない。私はGoogleでStackOverflowを検索しましたが、理解できるものは見つけられません...私はフランスのみのオートコンプリートをしたいと思います。どのようにGmaps4railsとオートコンプリートを実装する
だから私はこれをしようとしたが、このコードは
マイビュー(スクリプトおよびフォーム)
<%= form_tag(result_path, method: :get) %>
<%= text_field_tag :query, params[:query], class:"search-query form-control", placeholder:"Ex: Corse, Arcachon..." %>
<%= submit_tag "Partez", class:"btn btn-danger", name: nil %>
<script>
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
$(document).ready(initialize_gmaps_autocomplete_user_address());
function initialize_gmaps_autocomplete_user_address() {
var input = document.getElementById('query');
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.setTypes(['geocode']);
}
</script>
コントローラ
@hash = Gmaps4rails.build_markers(@campings) do |camping, marker|
marker.lat camping.latitude
marker.lng camping.longitude
marker.infowindow render_to_string(:partial => "/campings/infowindow", :locals => { :camping => camping})
marker.picture ({
"url" => "http://avantjetaisriche.com/map-pin.png",
"width" => 29,
"height" => 32})
私application.js
/= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require underscore
//= require gmaps/google
//= validyoutube
//= require_tree .
を動作しません。
私を助けることができますか?ありがとう。
あなたの返信に感謝:)私はこれを試してみます。 – nicolaswecandoit