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 using getBoundsZoomLevel,
> > 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
-~----------~----~----~----~------~----~------~--~---