0

I am using HERE map SDK in my Android app, I get geo location (lat/lon) every 5 seconds. When move the marker from location 1 to location 2, the marker jumps from location 1 to location 2. Does HERE map SDK have an api to move the marker smoothly from location 1 to location 2?

Michael
  • 1
  • 1

1 Answers1

0

heres how i did it .

before i start tracking the user' location i get his last known location wiht this line of code :

if (isLocationEnabled()) {
            LocationThread thread = new LocationThread(this, location ->{
                clearPassageiroMapMarker();
                passageiro.setLat(location.getLatitude());
                passageiro.setLongitude(location.getLongitude());
                addPassageiroMarker(new GeoCoordinates(location.getLatitude(),location.getLongitude()),R.drawable.ic_passageiro);

                return null;
            });
            thread.requestLocation();

notice that i add its marker ONCE and only once .. heres the code for that :

public void addPassageiroMarker(GeoCoordinates geoCoordinates, int resourceId) {
    MapImage mapImage = MapImageFactory.fromResource(this.getResources(), resourceId);
    Anchor2D anchor = new Anchor2D(0.5f, 1.0f);
    mapMarker = new MapMarker(geoCoordinates, mapImage, anchor);

    mapView.getMapScene().addMapMarker(mapMarker);
    mapMarkerPassageiroList.add(mapMarker);
}

notice that i have a mapmarker declared globably ,because im planning on using only one instance of marker throughout the entire instance of the activity...

heres the line of code that updates the marker whenever u get new set of coordinates :

mapMarker.setCoordinates(new GeoCoordinates(location.getLatitude(),location.getLongitude()));

took me a long while to find it out but im glad i did. however i think if ur loooking for a fancy way of displaying the marker moving like uber has etc, u might have to create an animation of your own.