2016-10-23 6 views
0

정말 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 . 

도와 주시겠습니까? 감사.

답변

0

당신이 도움이 GitHub의 게시물을 통과하려고 할 수 있습니다, 당신은 구현을 시작 돕기 위해 :

, 또한 가능했다 Place Autocomplete을 통과 해보세요 장소 자동 완성 요청은 다음의 HTTP URL임을 나타냅니다.

https://maps.googleapis.com/maps/api/place/autocomplete/output?parameters 

원하는 언어로 설정하려면 language 매개 변수를 원하는 언어 코드와 동일한 값으로 요청에 추가하십시오. list of supported languages 및 해당 코드를 참조하십시오.

gmaps4rails with Google Maps searchbox의 솔루션을 확인하고 도움이되는지 확인해보십시오.

+0

답장을 보내 주셔서 감사합니다 :) 나는 이것을 시도 할 것입니다. – nicolaswecandoit