mapbox sdkを使用してマップにバスの位置を示すアンドロイドアプリを作成しています。 Uberアプリのように、位置に基づいてマーカーを回転したいと思います。 どうすればいいですか?MapBoxのマーカーの方向アンドロイド
コード:
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 –