thanks for your hint, i will use getBoundsZoomLevel()

previously i had something like this:
        LatLng point1 = LatLng.newInstance(minLatitude, minLongitude);
        LatLng point2 = LatLng.newInstance(maxLatitude, maxLongitude);
        double distance = point1.distanceFrom(point2);
        int zoomLevel = new GZoomLevels().getZoomLevelForDistance(distance);

public class GZoomLevels {
    List<Integer> meters = new ArrayList<Integer>();

    public GZoomLevels() {
        meters.add(10000000); // 0
        meters.add(5000000); // 1
        meters.add(3000000); // 2
        meters.add(2000000); // 3
        meters.add(1000000); // 4
        meters.add(500000); // 5
        meters.add(200000); // 6
        meters.add(100000); // 7
        meters.add(50000); // 8
        meters.add(20000); // 9
        meters.add(10000);  // 10
        meters.add(5000); // 11
        meters.add(2000); // 12
        meters.add(1000); // 13
        meters.add(500); // 14
        meters.add(200); // 15
        meters.add(150); // 16
        meters.add(100); // 17
        meters.add(50); // 18
        meters.add(20); // 19
    }

    public int getZoomLevelForDistance(Double distandeInMeters) {
        int zoomLevel = 0;
        if (distandeInMeters.intValue()==0) {
            return 19;
        }
        for (int i = 0; i < meters.size(); i++) {
            if (meters.get(i) <= distandeInMeters.intValue()) {
                zoomLevel = i + 2;
                break;
            }
        }
        return zoomLevel;
    }
}

but using foreign code is preferred in many ways :)
thanks for your hint!

2009/8/10 Michael W <[email protected]>

>
> I had a blog for Google map auto zoom.
>
> http://michaeltechzone.blogspot.com/2008/12/google-maps-api-dynamically-calculate_31.html
> There is example of using it: http://www.allhotelmotel.com
>
> For GWT,
> you can reference bestFitWithCenter method and apply to your GWT
> module.
>
> I used it for my client new site, in hotel search result page map view
> tab.
> http://www.holidayinn.com/hotels/us/en/reservation
>
>
> On Aug 10, 1:59 am, lumo <[email protected]> wrote:
> > Hello NG!
> >
> > i am painting multiple markers on a map and need to change the zoom
> > level afterward so the user can see all of the markers in the viewing
> > area.
> > i already calculate the center position right, but deciding the zoom
> > level brings me to a problem.
> >
> > how can i calculate which zoom level i need? is there a special sense
> > behind the levels?
> >
> > i found an article about the scale of the levels, but i am not sure if
> > this is correct...http://laudontech.com/GISBlog/?p=28
> > would be great if someone can bring light into this (for me)
> >
> > thanks a lot in advance
> > lumo
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to