ruby on rails - Add a different marker on gmaps4rails -
i have hash of markers display products avaible in area user search location geocoder searchbox , map center on adress give user display 1 marker on adress, want know how display hash + 1 marker position give geocoder
my controller
if params[:bien_type].present? && params[:location].present? && params[:nbroom].present? @biens = bien.near(params[:location]).where(bien_type: params[:bien_type]) && bien.near(params[:location]).where(nbroom: params[:nbroom]) @hash = gmaps4rails.build_markers(@biens) |bien, marker| marker.lat bien.latitude marker.lng bien.longitude marker.infowindow "<h2>#{bien.name}</h2><a target='blank' href='http://"+"#{bien.url}'>visiter</a><h3>#{bien.adress}</h3><h3>#{bien.bien_type}</h3><h3>#{bien.nbroom} pièces</h3><h3>vendu il y #{((date.today - bien.sell_date.to_date) / 7).round} semaines</h3>" marker.picture({ :url => actioncontroller::base.helpers.asset_path("icohouse.png"), "width" => 80, "height" => 80}) end
my map
<% content_for(:after_js) %> <%= javascript_tag %> $(document).ready(function() { var handler = gmaps.build('google'); handler.buildmap({provider: {scrollwheel: false, zoomcontrol: false, styles: [...]}, internal: { id: 'map' } }, function() { markers = handler.addmarkers(<%= raw @hash.to_json %>); handler.bounds.extendwith(markers); handler.addmarker(<%= geocoder.coordinates(params[:location]) %>); handler.fitmaptobounds(); if (markers.length == 0) { handler.getmap().setzoom(16) handler.map.centeron(<%= geocoder.coordinates(params[:location]) %>); } else if (markers.length == 1) { handler.map.centeron(<%= geocoder.coordinates(params[:location]) %>); handler.getmap().setzoom(16); } }); }); <% end %> <% end %>
Comments
Post a Comment