Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. <script src="/assets/typeahead.js" type='text/javascript'></script>
  2. <script src="/assets/typeahead-addresspicker.js" type='text/javascript'></script>
  3. <!-- for search input END -->
  4.  
  5. <!-- for MAP -->
  6. <script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js' type='text/javascript'></script>
  7. <!-- for MAP END -->
  8.  
  9. <%= form_tag search_path, :method => :get do %>
  10. <div class="input-group input-group-sm" id="The-Basics">
  11.  
  12. <%= text_field_tag :q, params[:q], class: 'form-control typeahead input-sm', id: 'pac-input', :placeholder => 'Enter City, State or Zip!', :autofocus => true %>
  13.  
  14. <span class="input-group-btn">
  15. <%= submit_tag "Go", :name => nil, class: 'btn btn-primary btn-sm', id: '', data: { no_turbolink: true } %>
  16. </span>
  17. </div>
  18. <% end %>
  19.  
  20. ----other content here------
  21.  
  22. <!-- Gmaps -->
  23. <div id="rightCol">
  24. <div id="map-canvas"></div>
  25. <!-- Gmaps End -->
  26.  
  27. <script type="text/javascript">
  28. //google maps
  29. handler = Gmaps.build('Google',
  30. {
  31. markers: {
  32. clusterer: {
  33. gridSize: 10, maxZoom:15
  34. }
  35. }
  36. });
  37.  
  38. handler.buildMap({
  39. provider: {
  40. disableDefaultUI: false
  41. // pass in other Google Maps API options here
  42. },
  43. internal: {
  44. id: 'map-canvas'
  45. }
  46. },
  47. function(){
  48. markers = handler.addMarkers(<%=raw @hash.to_json %>);
  49.  
  50. handler.bounds.extendWith(markers);
  51. handler.fitMapToBounds();
  52. handler.getMap().setZoom(9);
  53. handler.map.centerOn;
  54. }
  55. );
  56.  
  57. // AUTO COMPLETE FOR SEARCH
  58.  
  59. // mobile address picker
  60. var addressPicker = new AddressPicker({
  61. autocompleteService: {
  62. types: ['(cities)'],
  63. componentRestrictions: { country: 'US' }
  64. }
  65. }
  66. );
  67.  
  68. $('#pac-input').typeahead(null, {
  69. displayKey: 'description',
  70. source: addressPicker.ttAdapter()
  71. });
  72.  
  73. // address picker main
  74. var addressPicker = new AddressPicker({
  75. autocompleteService: {
  76. types: ['(cities)'],
  77. componentRestrictions: { country: 'US' }
  78. }
  79. }
  80. );
  81.  
  82. $('#pac-input2').typeahead(null, {
  83. displayKey: 'description',
  84. source: addressPicker.ttAdapter()
  85. });
  86.  
  87. // AUTO COMPLETE FOR SEARCH END
  88.  
  89. def search
  90. @properties = Property.search_available_coming(params[:available_coming]).where(property_active: true).order(property_city: :asc).paginate(:page => params[:page], :per_page => 10)
  91. @hash = Gmaps4rails.build_markers(@properties) do |property, marker|
  92.  
  93. marker.lat property.latitude
  94. marker.lng property.longitude
  95. marker.picture({
  96. "url" => view_context.image_path("Orange-House-Icon.png"),
  97. "width" => 50,
  98. "height" => 50
  99. })
  100. marker.infowindow render_to_string( partial: 'layouts/mapinfo', locals: { property: property.id })
  101. marker.title "i'm the title"
  102. end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement