javascript - Gmaps4rails Gem show 2 markers for same address -


i trying implement gmaps4rails gem , geocoder gem, works fine. thing @ index.html.erb page, list boats , show map can not show more 1 marker if have more 1 same address. show like;

enter image description here

here locations_controller;

def index      if params[:search].present?          @locations = location.near(params[:search], 5) #kac mile cevresinde aranıldıgının bilgisi bu km ile değişebilir     else         @locations = location.all     end     @hash = gmaps4rails.build_markers(@locations) |location, marker|         marker.lat location.latitude         marker.lng location.longitude         marker.infowindow render_to_string(:partial => "/locations/my_template", :locals => { :object => location})      end   end 

this index.html.erb;

<script src="//maps.google.com/maps/api/js?v=3.13&amp;sensor=false&amp;libraries=geometry" type="text/javascript"></script> <script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js' type='text/javascript'></script>  <h3>nearby locations</h3> <ul> <% @locations.each |location| %>   <li><%=location.address %></li> (<%= location.distance.round(2) %> miles)  <% end %> </ul>     <div style='width: 800px;'>   <div id="map" style='width: 800px; height: 400px;'></div> </div>  <script type="text/javascript"> handler = gmaps.build('google'); handler.buildmap({ provider: {}, internal: {id: 'map'}}, function(){   markers = handler.addmarkers(<%=raw @hash.to_json %>);   handler.bounds.extendwith(markers);   handler.fitmaptobounds(); }); </script> 

it shows 1 marker though have more 1 address same latitude , longitude. how can overcome it?

edit 1:

here looks like;

enter image description here

then zoom out;

enter image description here

and added said;

<script type="text/javascript"> handler = gmaps.build('google', { markers: { maxrandomdistance: 5 } }); handler.buildmap({ provider: {}, internal: {id: 'map'}}, function(){   markers = handler.addmarkers(<%=raw @hash.to_json %>);   handler.bounds.extendwith(markers);   handler.fitmaptobounds(); }); </script> 

its problem map: cant have 2 things @ same place.

since common issue, there option in gem though:

handler = gmaps.build('google', { markers: { maxrandomdistance: integerinmeters } }); 

this randomize coordinates give within maxrandomdistance distance of expected center


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -