How do I load only markers that are inside the map bounds with gmaps4rails? And of course load new ones after pan and/or zoom.
Directly related to that, how can I get the current boundaries and zoomlevel of the map?
How do I load only markers that are inside the map bounds with gmaps4rails? And of course load new ones after pan and/or zoom.
Directly related to that, how can I get the current boundaries and zoomlevel of the map?
Wow, you really provide much feedback for the gem :)
Here is how I use it:
to load only the useful markers, I filter them using geokit-rails3 and the following scope:
Location.in_bounds([@south_west_point, @north_east_point], :origin => @somewhere)
when zoom or span, I only rely on the clustering which fasten the process
to configure, map center and original zoom, see here
you should code yourself the method to get the current boundaries, consider pulling :)
Here is how I did it, I only replace the markers after the user finishes panning or zooming, if you require different behavior then use a different event listener:
In your view (index.html.erb):
At the bottom of your view add:
In application.js (using jQuery):
venues_controller#index:
Venue.rb model (using mongodb and mongoid):