4

I am working on an application in which map zoom level set on the basis on seekbar move say seekbar progress is 10 mile then calculate exact zoom level of map by which cover 10 mile distance on mobile screen map.more explanation in attached imageenter image description here

my seekbar initial position is 1 mile and max position is 50 miles when I move seekbar max position say 50 map cover only 30 km area while it should be cover 80 km area.I am using code for achieve this is -

private int zoomLevel(double _distance) {
    int newzoomlevel = 1;
    double distance = _distance * 1609.34;
    double equatorLength = 40075004; // in meters
    double widthInPixels = screenWidth();
    double metersPerPixel = equatorLength / 256;
    int zoomLevel = 1;
    while ((metersPerPixel * widthInPixels) > distance) {
        metersPerPixel /= 2;
        ++zoomLevel;
    }
    Log.i("current zoom level", "zoom level = " + zoomLevel);
    if (zoomLevel <=19) {
        newzoomlevel = zoomLevel;
    } else {
        newzoomlevel = zoomLevel - 2;
    }
    return newzoomlevel;

}

I am passing seekpar position as a parameter since it is in mile in method I convert it into meter by multiplying 1609.34. but my over all out come is not correct please any one guide me thanks in advance.

SKT
  • 253
  • 4
  • 15
  • I am still waiting for better solution,is anyone guide me? – SKT May 24 '13 at 06:42
  • I'm searching for the same thing with the new Maps api it's confusing In the old api I would use mercator projection and it's so easy then [a question that talks about that](http://stackoverflow.com/questions/14828217/android-map-v2-zoom-to-show-all-the-markers) but in the new I can't find that Maybe search `VisibleRegion` class – Driss Bounouar Jun 11 '13 at 09:08

0 Answers0