2016-04-13 2 views
0

Мне нужно повернуть карту вокруг текущего маркера местоположения. Текущий маркер местоположения будет помещен в загрузочный файл карты. Как на картинке. Map with location markerПоворот карты osmdroid вокруг произвольной точки

+0

Пожалуйста, объясните ваши требования. Вам нужна какая-то статическая карта? –

+0

Привет! Спасибо за ответ. Я уже нашел решение самостоятельно, но может быть, это худший вариант :) Было бы здорово, если бы вы могли улучшить этот код – BadEugene

ответ

0

я решил свою задачу с этим кодом:

//rotate map 
map.setMapOrientation(angle); 

//center to current location 
GeoPoint point = mMyLocationNewOverlay.getMyLocation(); 
if (point == null) return; 
mapController.setCenter(point); 

//calculate translation 
float bottomPadding = map.getHeight() * 0.1f; 
float radius = map.getHeight()/2 - bottomPadding; 
double deltaW = Math.sin(Math.toRadians(angle)); 
double deltaH = Math.cos(Math.toRadians(angle)); 

int width = map.getWidth()/2 - (int)(radius * deltaW); 
int height = map.getHeight()/2 - (int)(radius * deltaH); 

//Move current location marker to bottom of the map 
Projection projection = map.getProjection(); 
GeoPoint centerPoint = (GeoPoint) projection.fromPixels(width, height); 
mapController.setCenter(centerPoint); 
Смежные вопросы