0

I'm trying to understand how to animate markers when using mapbox-gl. I'm actually using the Xamarin binding of the 3.2.0.3 java library, so the problem might be there.

I'm using the examples that we can find on the GitHub page, and mainly this example. This example shows that a simple ValueAnimator modifying the Position of the MarkerOptions object is enough to achieve a movement.

All my attempts to move a marker failed: applying SetPosition on a MarkerOptions object has no effect.

I've tried temporary solutions, like removing all the markers and re-add them. Either in an animator or by making my own logic in the Update event. But of course, markers are flickering because modifications to the map are not perfectly sync'ed with the thread UI.

When reading the mapbox-gl source-code samples on the project page, it seems clear to me that using Animator on MarkerOptions is a good practice, but it just seems to fail no matter what I'm trying to do.

Summary: Invoking _myMarkerOptions.SetPosition(new LatLng(10, 10)); on an existing marker just has no effect.

Léon Pelletier
  • 2,701
  • 2
  • 40
  • 67

1 Answers1

2

Example of ValueAnimator will only work with the upcoming release of 4.0.0. Before this release the Marker.setPosition was package private and not accessible for external usage. Invoking setPosition on MarkerOptions doesn't have any effect because it's a builder for a marker object, not the marker itself.

For now the only way possible is removing and readding the marker.

Tobrun
  • 18,291
  • 10
  • 66
  • 81