Iβm working on an application in which the map zoom level, based on the movement of the search key, says the search step is 10 miles, and then calculate the exact scale scale of the map, which extends the distance of 10 miles on the map of the mobile screen. A more detailed description in the attached image 
my starting position for the search appliance is 1 mile and the maximum position is 50 miles when I move the maximum position in the search bar. Say, 50 maps cover only an area of ββ30 km, while it should be covered with an area of ββ80 km. I use code to achieve this -
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 pass the seekpar position as a parameter since it is a mile in the method. I convert it to meter, multiplying 1609.34. but I canβt say that itβs not right, please help me in advance.
source share