我正在使用mapbox sdk創建一個顯示公交車位置的android應用程序。 我想像Uber應用那樣根據位置旋轉標記。 我怎麼能做到這一點?MapBox中的標記方向android
代碼:
IconFactory iconFactory = IconFactory.getInstance(navigationActivity.this);
Drawable iconDrawable = ContextCompat.getDrawable(navigationActivity.this, R.drawable.bus);
Icon icon = iconFactory.fromDrawable(iconDrawable);
map.clear();
CameraPosition position = new CameraPosition.Builder()
.target(new LatLng(lat,lon)) // Sets the new camera position
.zoom(16) // Sets the zoom
.bearing(180) // Rotate the camera
.tilt(30) // Set the camera tilt
.build(); // Creates a CameraPosition from the builder
map.animateCamera(CameraUpdateFactory
.newCameraPosition(position), 7000);
final Marker marker = map.addMarker(new MarkerOptions()
.position(new LatLng(lat,lon))
.title("You!")
.snippet("YOu are Currently here."));
marker.setIcon(icon);
你沒有提到你所面對的問題!你已經在代碼 – Stallion
中實現了軸承和傾斜功能。當地圖加載時,它將生成動畫並旋轉。但是當另一個地點進入另一條水平線路時,公交車圖標將沿着垂直方向進入該道路,標記的圖像是..我需要它水平對齊@Stallion –