sg

Salı, Ocak 17, 2006

Auto Zoom


I have changed most of my code to work w/ the new API (version 2). The
problem that I am having now is auto zoom. I have found the following
code which is helpful, but doesn't quite do the job all the time. This
is what I have so far:

var bounds = new GLatLngBounds;
for (var m=0; m!=gmarkers.length; m++) {
bounds.extend(gmarkers[m].point);
}
var zoom = map.getBoundsZoomLevel(bounds);
zoom--;
map.setZoom(zoom);

gmarkers is an array of markers.

On the page where I am displaying my map, you can do a search for
locations either by zip code or city/state, hence the need to adjust
the zoom based on the results. In one instance, I had the following
lats and longs:

<markers>
<marker>
<lat>38.259112</lat>
<long>-85.705955</long>
<preferred>Y</preferred>
</marker>
<marker>
<lat>38.258646</lat>
<long>-85.704547</long>
<preferred>N</preferred>
</marker>
<marker>
<lat>38.253534</lat>
<long>-85.700684</long>
<preferred>N</preferred>
</marker>
</markers>

What I've noticed is that if I don't keep the zoom--; line in, it seems
to ignore the third marker in this case. I've added an alert box in
the loop to ensure that all markers are being looped through and they
are. But the getBoundsZoomLevel seems to only focus on the first two.
I'm not sure if it's because they are the closest two points of if it
is something else entirely. I would post a link to my page, but it's
still under development (meaning intranet access only).

Thanks for any help in advance,
NeoCool

0 Comments:

Yorum Gönder

<< Home


Komik Videolar   islam  şarkı sözleri  yemek tarifleri  gelibolu  huzur   sağlık