Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void animateMarkerList( final Marker marker,
- final boolean hideMarker,
- final List<LatLng> lista) {
- final Handler handler = new Handler();
- final long start = SystemClock.uptimeMillis();
- Projection proj = mMap.getProjection();
- Point startPoint = proj.toScreenLocation(marker.getPosition());
- final LatLng startLatLng = proj.fromScreenLocation(startPoint);
- final long duration = 1000;//1 second
- final LatLng toPosition = lista.get(0);
- final Interpolator interpolator = new LinearInterpolator();
- handler.post(new Runnable() {
- @Override
- public void run() {
- long elapsed = SystemClock.uptimeMillis() - start;
- float t = interpolator.getInterpolation((float) elapsed
- / duration);
- double lng = t * toPosition.longitude + (1 - t) * startLatLng.longitude;
- double lat = t * toPosition.latitude + (1 - t) * startLatLng.latitude;
- marker.setPosition(new LatLng(lat, lng));
- if (t < 1.0) {
- // Post again 16ms later.
- handler.postDelayed(this, 16);
- } else {
- lista.remove(0);
- if(lista.size()>0){
- animateMarkerList(marker,hideMarker,lista);
- }
- else{
- if (hideMarker) {
- marker.setVisible(false);
- } else {
- marker.setVisible(true);
- }
- }
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement