2016-04-13 48 views
0

現在の位置マーカーを中心に地図を回転させる必要があります。現在の位置マーカーはマップのブートトゥームに配置されます。写真のように。任意の点を中心にosmdroid地図を回転する

+0

が要件を教えてください。ある種の静的地図が必要ですか? –

+0

こんにちは!ご回答いただきありがとうございます。私はすでに自分自身で解決策を見つけましたが、最悪の変種かもしれません:)このコードを改善できれば素晴らしいでしょう – BadEugene

答えて

0

Map with location marker私はこのコードで自分のタスクを解く:

//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); 
関連する問題