I'm looking for a way for a gmap view to remember its zoom level and centre if the view is refreshed, eg after changing exposed filter values.
Here's a gmap view that shows photos of Hong Kong, located by where they were taken, and with the option to select a date range for when the photos were taken:
http://www.batgung.com/hong-kong-photo-map
If I zoom in on the map, eg to just look at Hong Kong island, there are still too many markers. So then I might narrow down the date range, eg 1900-1930 and click 'search'. But that refreshes the view which means the map goes back to its default zoom & centre.
I'd welcome any suggestions on how to keep the zoom and centre. I'm thinking when the 'search' button is clicked there would be some javascript that queries the google map for current zoom and centre, and then builds those values into the url of the next query.
Then after the new view is displayed, there would be javascript that reads the url and sets the zoom & centre.
Does that sound doable, or is there a better / easier way? I'm using Drupal 5 with gmap, location, and views.
Thanks, MrB
Comments
Some javascript tips
I think you'll need to use some javascript, to save the current center use something along the lines of:
var center = map.getCenter();and then to set the center of the new map
map.setCenter(center);Hope this helps. It might be worth moving this discussion into the issues queue for the gmap module - there may be more people there who could help.
http://www.thomasturnbull.com
http://twitter.com/thomasturnbull
Thanks Tom, I'll look at the
Thanks Tom, I'll look at the javascript you suggested. I've opened issue http://drupal.org/node/224702 for any further comments.