javaandroidheremapshere-maps-restheremaps-android-sdk

Animate marker location to another in HEREMAPS


currently, i'm developing a map application similar to uber, and since im using Googles location service " intermitent thread " , i get the users location every 10-20-30 seconds and i update its new location on the map, by simply cleaning the existing List , and inserting another mark inside of it.

That makes it looks like the users icon is literally " teleporting " across the map.

ive made some researches and i was unable to find examples or of its possible to be done in Heremaps explorer edition.

I'm aware that all i gotta do is work with only one object instead of clearing my list and placing another object in it.

Any help would be appreciated, thanks in advance.


Solution

  • With the Explore Edition of the HERE SDK you can use the flyTo() method of the MapCamera. The speed and type of the animations between two distinctive coordinates can be heavily customized.

    Just to give a simple example how you can move between two coordinates without "teleporting":

    private void flyTo(GeoCoordinates geoCoordinates) {
        GeoCoordinatesUpdate geoCoordinatesUpdate = new GeoCoordinatesUpdate(geoCoordinates);
        double bowFactor = 1;
        MapCameraAnimation animation =
                MapCameraAnimationFactory.flyTo(geoCoordinatesUpdate, bowFactor, Duration.ofSeconds(3));
        mapCamera.startAnimation(animation);
    }
    

    Whenever you set a new coordinate as target to the camera, it will instantly switch to that location - hence it looks like teleporting. With a linear (or bow like above) animation it will look smoother and in fact the coordinates between the previous and the new location are "interpolated".

    With the Navigate Edition, there's also an InterpolationListener, which can be used to provide smooth interpolated location updates when a positioning source is used.