Я хочу, чтобы изображение было увеличено до радиуса 1 км, но не могу понять, как?
Док говорит, что уровень масштабирования 1 будет отображать экваториальные экваторы на 256 пикселей. Итак, как я могу рассчитать, какой уровень масштабирования мне нужно установить, чтобы вид карты отображал область в радиусе 1KM?
UPDATE:
Прочитав несколько сообщений в блоге, я написал следующий код:
private int calculateZoomLevel() {
double equatorLength = 6378140; // in meters
double widthInPixels = screenWidth;
double metersPerPixel = equatorLength / 256;
int zoomLevel = 1;
while ((metersPerPixel * widthInPixels) > 2000) {
metersPerPixel /= 2;
++zoomLevel;
}
Log.i("ADNAN", "zoom level = "+zoomLevel);
return zoomLevel;
}
Идея состоит в том, что сначала я вычисляю Метры на пиксель на уровне масштабирования 1, который согласно google показывает экватор земли с использованием 256 пикселей. Теперь каждый последующий уровень увеличения увеличивается на уровень 2, поэтому я половину метров на пиксель для каждого уровня масштабирования. Я делаю это, пока у меня не будет уровня масштабирования, где метры на пиксель, умноженные на ширину экрана , дает мне меньше 2000 i.e 2 км в поперечнике.
Но я не думаю, что уровень масштабирования, который я получаю, показывает карту радиуса 2Km. Может кто-нибудь сказать мне, что я делаю неправильно здесь?