I too am having this issue.

I'm actually collecting the bounds as I add markers to the map. Once
they're all added, I have a bounds value of: (42.828438, -9653172),
(58.467977, 6.99358)

Then running this:

var zoom = myMap.getBoundsZoomLevel(bounds);
var center = bounds.getCenter();
myMap.setCenter(center, zoom);

(running myMap.setCenter(bounds.getCenter(), myMap.getBoundsZoomLevel
(bounds)) has exactly the same problem)

...always returns zero for zoom, despite the fact that the markers are
in the UK and France only. Naturally, as the zoom is zero, the
setCentre doens't operate as required either. I've also tried
checkResize() before determining the zoom level and this has no effect
either.

You can see my code running here: 
http://www.holiday-chateau.com/index.php?id=10790

The map is on the second tab in and starts to load markers before you
activate the tab.

On Sep 25, 11:04 am, Jake <[email protected]> wrote:
> On Sep 25, 12:52 am, "[email protected]" <[email protected]>
> wrote:
>
>
>
> > On Sep 24, 8:40 pm, Jake <[email protected]> wrote:
>
> > > I am trying to zoom in on some points usinggetBoundsZoomLevel,
> > > however it always returns zero here:
>
> > >http://devasp.northcarolina.edu/iic/exams/find.php?q[text]=&q[location]=rocky+mount%2C+nc
>
> > > Specifically around line 103 in this 
> > > file:http://devasp.northcarolina.edu/iic/exams/testmap.js
>
> > > From some alerts I added:
> > > South West is 35.9766893 -77.8964899
> > > North East is 35.9414508 -77.7972611
>
> > > How can I get it to return the right zoom level?
>
> > Why are you doing this?
> > if (new_markers.length > 1 ) {
> > var bounds = new GLatLngBounds(new_markers[0].getLatLng(), new_markers
> > [1].getLatLng());
>
> > }
>
> > for (var i=2; i < new_markers.length; i++) {
> >   bounds.extend(new_markers[i].getLatLng())
>
> > }
>
> > The first part gets the order wrong and makes the bounds cover the
> > whole world.  If you combine them into a single loop instead, you not
> > only make your life easier, but it works:
>
> > var bounds = new GLatLngBounds();
> > for (var i=0; i < new_markers.length; i++) {
> >   bounds.extend(new_markers[i].getLatLng())
>
> > }
>
> > and you can make your code even more efficient by adding the markers
> > at the same time rather than looping through the array a second time
> > to add them...
>
> >  -- Larry
>
> Ok, I see what you are saying.  I didn't think about that.
>
> I did it like that because there may only be one point and I didn't
> want to create bounds for one point.  But I guess there's nothing
> really wrong with that.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to