Search in sources :

Example 1 with PlacemarkMapObject

use of com.yandex.mapkit.map.PlacemarkMapObject in project react-native-yamap by volga-volga.

the class YamapMarker method animatedMoveTo.

public void animatedMoveTo(Point point, final float duration) {
    PlacemarkMapObject placemark = (PlacemarkMapObject) this.getMapObject();
    Point p = placemark.getGeometry();
    final double startLat = p.getLatitude();
    final double startLon = p.getLongitude();
    final double deltaLat = point.getLatitude() - startLat;
    final double deltaLon = point.getLongitude() - startLon;
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
    valueAnimator.setDuration((long) duration);
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            try {
                float v = animation.getAnimatedFraction();
                moveAnimationLoop(startLat + v * deltaLat, startLon + v * deltaLon);
            } catch (Exception ex) {
            // I don't care atm..
            }
        }
    });
    valueAnimator.start();
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) Point(com.yandex.mapkit.geometry.Point) ValueAnimator(android.animation.ValueAnimator) PlacemarkMapObject(com.yandex.mapkit.map.PlacemarkMapObject)

Example 2 with PlacemarkMapObject

use of com.yandex.mapkit.map.PlacemarkMapObject in project react-native-yamap by volga-volga.

the class YamapMarker method moveAnimationLoop.

public void moveAnimationLoop(double lat, double lon) {
    PlacemarkMapObject placemark = (PlacemarkMapObject) this.getMapObject();
    placemark.setGeometry(new Point(lat, lon));
}
Also used : Point(com.yandex.mapkit.geometry.Point) PlacemarkMapObject(com.yandex.mapkit.map.PlacemarkMapObject)

Example 3 with PlacemarkMapObject

use of com.yandex.mapkit.map.PlacemarkMapObject in project react-native-yamap by volga-volga.

the class YamapView method updateUserLocationIcon.

private void updateUserLocationIcon() {
    if (userLocationView != null) {
        PlacemarkMapObject pin = userLocationView.getPin();
        PlacemarkMapObject arrow = userLocationView.getArrow();
        if (userLocationBitmap != null) {
            pin.setIcon(ImageProvider.fromBitmap(userLocationBitmap));
            arrow.setIcon(ImageProvider.fromBitmap(userLocationBitmap));
        }
        CircleMapObject circle = userLocationView.getAccuracyCircle();
        if (userLocationAccuracyFillColor != 0) {
            circle.setFillColor(userLocationAccuracyFillColor);
        }
        if (userLocationAccuracyStrokeColor != 0) {
            circle.setStrokeColor(userLocationAccuracyStrokeColor);
        }
        circle.setStrokeWidth(userLocationAccuracyStrokeWidth);
    }
}
Also used : CircleMapObject(com.yandex.mapkit.map.CircleMapObject) PlacemarkMapObject(com.yandex.mapkit.map.PlacemarkMapObject)

Example 4 with PlacemarkMapObject

use of com.yandex.mapkit.map.PlacemarkMapObject in project react-native-yamap by volga-volga.

the class YamapMarker method rotateAnimationLoop.

public void rotateAnimationLoop(float delta) {
    PlacemarkMapObject placemark = (PlacemarkMapObject) this.getMapObject();
    placemark.setDirection(delta);
}
Also used : PlacemarkMapObject(com.yandex.mapkit.map.PlacemarkMapObject)

Example 5 with PlacemarkMapObject

use of com.yandex.mapkit.map.PlacemarkMapObject in project react-native-yamap by volga-volga.

the class YamapMarker method animatedRotateTo.

public void animatedRotateTo(final float angle, float duration) {
    PlacemarkMapObject placemark = (PlacemarkMapObject) this.getMapObject();
    final float startDirection = placemark.getDirection();
    final float delta = angle - placemark.getDirection();
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
    valueAnimator.setDuration((long) duration);
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            try {
                float v = animation.getAnimatedFraction();
                rotateAnimationLoop(startDirection + v * delta);
            } catch (Exception ex) {
            // I don't care atm..
            }
        }
    });
    valueAnimator.start();
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ValueAnimator(android.animation.ValueAnimator) PlacemarkMapObject(com.yandex.mapkit.map.PlacemarkMapObject)

Aggregations

PlacemarkMapObject (com.yandex.mapkit.map.PlacemarkMapObject)6 ValueAnimator (android.animation.ValueAnimator)2 LinearInterpolator (android.view.animation.LinearInterpolator)2 Point (com.yandex.mapkit.geometry.Point)2 CircleMapObject (com.yandex.mapkit.map.CircleMapObject)2 PolygonMapObject (com.yandex.mapkit.map.PolygonMapObject)1 PolylineMapObject (com.yandex.mapkit.map.PolylineMapObject)1