What I'd like to do: In this code I've instantiated a symbol with a camera position. All I'd like to do is animate the symbol on the map to another set of coordinates that I would hardcode in, for now. I've tried many things but can't figure out how to get this to work.
What I've Tried: I've seen two examples for the Mapbox Android SDK and have tried variations of these just to get the marker moving to another point but I'm very lost:
This example uses Object Animator: https://docs.mapbox.com/android/maps/examples/animate-marker-position/
This example doesn't use any Animators and just updates the symbol based on coordinates: https://docs.mapbox.com/android/maps/examples/api-response-icon-update/
Where I'm at Now: I finally decided to just update the symbol and the documentation pointed me to use this:
AnnotationManager.update(Annotation).
but I'm not sure how. Please help I've been stuck for a very long time and I'm feeling lost. Thanks.
Symbol Reference Saying To Use This: https://docs.mapbox.com/android/api/plugins/annotation/0.4.0/com/mapbox/mapboxsdk/plugins/annotation/Symbol.html#setLatLng-LatLng-
Image of what I'd like to Happen: Animate Symbol To Point
P.S. Should I just try the Object Animator?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Mapbox.getInstance(this, getString(R.string.access_token));
setContentView(R.layout.activity_main);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
mapboxMap.setStyle(Style.LIGHT, new Style.OnStyleLoaded(){
@Override
public void onStyleLoaded(@NonNull Style style){
//Import Icon
Bitmap icon = BitmapFactory.decodeResource(getResources(),
R.drawable.blue_icon);
style.addImage(ID_IMAGE_SOURCE, icon);
style.addSource(new GeoJsonSource("source-id"));
//Create Symbol
SymbolManager symbolManager = new SymbolManager(mapView, mapboxMap, style);
symbolManager.setIconAllowOverlap(true);
symbolManager.setIconIgnorePlacement(true);
Symbol symbol = symbolManager.create(new SymbolOptions()
.withLatLng(new LatLng(33.718492, -117.796390))
.withIconImage(ID_IMAGE_SOURCE)
.withIconSize(.25f));
//Camera Position and Bounds
LatLngBounds latLngBounds = new LatLngBounds.Builder()
.include(new LatLng(33.717872, -117.796296))
.include(new LatLng(33.718342, -117.797975))
.build();
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds,
30));