0
我需要圍繞當前位置標記旋轉我的地圖。當前位置標記將被放置在地圖的引導處。就像一張照片。 Map with location marker圍繞任意點旋轉osmdroid地圖
我需要圍繞當前位置標記旋轉我的地圖。當前位置標記將被放置在地圖的引導處。就像一張照片。 Map with location marker圍繞任意點旋轉osmdroid地圖
我解決了我的任務,此代碼:
//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);
請說明您的需求。你需要某種靜態地圖嗎? –
嗨!感謝您的迴應。我自己已經找到了解決方案,但可能是最糟糕的變體:)如果您可以改進此代碼,那將是非常棒的 – BadEugene