u1072113 / jquery-ui-map

Automatically exported from code.google.com/p/jquery-ui-map
0 stars 0 forks source link

clear('markers') does not reset bounds #42

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

marker1, marker2 are closer than marker1, marker3 (so the bounds will be wider, 
here, to illustrate the point better)

1. Add a gmap()
2. Add marker1, bounds = True
3. Add marker2, bounds = True
4. Clear all markers
5. Add marker1, bounds = True
6. Add marker3, bounds = True
7. Clear all markers
8. Add marker1, bounds = True
9. Add marker2, bounds = True

What is the expected output? What do you see instead?

Bounds should be the same for 2, 3 and 8,9, but because the bounds do not reset 
with from the 'clear' on Step 7, the bounds are the same as they were for 5, 6 

What version of the product are you using? On what operating system?

3.0-rc1, Ubuntu 11.10

Please provide any additional information below.

Original issue reported on code.google.com by timrcha...@gmail.com on 9 Apr 2012 at 8:06

GoogleCodeExporter commented 8 years ago
The solution seems to be to not use {'bounds': true} and extend a 
google.maps.LatLngBounds object with all the marker positions and pass it to a 
$('#map').gmap('get', 'map').fitBounds() call

Original comment by timrcha...@gmail.com on 9 Apr 2012 at 9:00

GoogleCodeExporter commented 8 years ago
s/solution/workaround/g

Original comment by timrcha...@gmail.com on 9 Apr 2012 at 9:00

GoogleCodeExporter commented 8 years ago
Yep, it will only get wider and wider unless you specifically set bounds to 
null, $('#x').gmap('set', 'bounds', null). 
Just reset the bounds variable to null then clearing. 

Original comment by johansalllarsson on 9 Apr 2012 at 9:02

GoogleCodeExporter commented 8 years ago
I think you could call clear like this too $('#x').gmap('clear', 'bounds');

Original comment by johansalllarsson on 9 Apr 2012 at 9:04

GoogleCodeExporter commented 8 years ago
Thanks for the tips.  I'll give 'em a spin later this evening.

Original comment by timrcha...@gmail.com on 9 Apr 2012 at 9:39

GoogleCodeExporter commented 8 years ago
I do not believe $('#x').gmap('clear', 'bounds') works, but $('#x').gmap('set', 
'bounds', null) does.

Have you thought about maybe adding a 'reset' API call which will reset the 
gmap instance to its initial state (e.g. $('#x').gmap(options))?  Not sure how 
you'd feel about that.

Original comment by timrcha...@gmail.com on 10 Apr 2012 at 4:19