Question about the chevron

Hi, I have a question about the chevron.

I add the chevron using the following snippet.

ChevronBuilder chevronBuilder = ChevronBuilder.create(activeIcon, inactiveIcon);
chevron = tomtomMap.getDrivingSettings().addChevron(chevronBuilder);

It works fine, but the chevron shows up in the middle of the Atlantic Ocean. I guess it becomes active, and adjusts its position to the user’s current position when the user is driving or moving?

Is there a way to set an initial position of the chevron? Or is there anything that I am missing?

Hi,

There is a possibility to set initial position in the ChevronBuilder by passing a ChevronPosition class to the builder:

    ChevronBuilder chevronBuilder = ChevronBuilder.create(activeIcon, inactiveIcon)
            .initialPosition(chevronPosition);

    chevron = tomtomMap.getDrivingSettings().addChevron(chevronBuilder);

Hi, Damian

Thank you for the reply.

I tried setting the initial position with below code, but didn’t have a luck to make it work.

ChevronPosition chevronPosition = new ChevronPosition.Builder(new LatLng(lat, lon), 0).build();
ChevronBuilder chevronBuilder = ChevronBuilder.create(activeChevron, inactiveChevron)
                .initialPosition(chevronPosition);
chevron = tomtomMap.getDrivingSettings().addChevron(chevronBuilder);

Because the chevron didn’t move, I checked the coordinates of the chevron with below code. It seems the coordinates are updated fine, showing the correct numbers.

chevron.getPosition().getCoordinates()

However, the map is still showing the chevron in the middle of the ocean. Have you ever had this kind of issue?

It might be happening because time stamp is set to 0.

Can you try obtaining current time in millis like this:
long currentTimeInMillis = System.currentTimeMillis()

And pass it to the ChevronPosition builder:

ChevronPosition chevronPosition = new ChevronPosition.Builder(new LatLng(lat, lon), currentTimeInMillis).build();

Yes, I passed the timestamp as explained, and now it is working fine.

Thank you, Damian

1 Like

Have few more questions.

The chevron’s initial position is now correctly assigned and updated, but the map is showing the chevron’s icon as inactive mode.

Does the icon automatically change to the active mode when the user starts moving?

Or do I need to manually update the location/coordinates of the chevron?

Chevron by default is set as inactive. To make it move as user is moving I would register an LocationUpdateListener in TomTomMap and whenever new location update is available you pass it to the chevron aswell.

Something like this:

    @Override
public void onLocationChanged(Location location) {
    ChevronPosition chevronPosition = new ChevronPosition.Builder(location).build();

    chevron.setDimmed(false); //this makes your chevron active
    chevron.setPosition(chevronPosition);
    chevron.show(); //used only if your logic hides chevron in some circumstances
}

And to make your chevron inactive which indicates e.g., that location is too inaccurate simply call

chevron.setDimmed(true)

1 Like

I see. I can just implement the LocationUpdateListener. Thank you for the answer. It helped a lot.

1 Like

Hello @Flyentology12 , @kyungsuksong,
I was also using chevron and tracking feature to track user location. But when I take turn left or right or takes U turn on road, position of chevron changes but camera position i.e. bearing don’t change.
So any idea about this ?

Hello @gauravgavhane I have the exact same problem as you both in android and iOS. Did you manage to solve the issue?

Hi,

Have you enabled a tracking mode for the Chevron using drivingSettings.startTracking(chevron) method?

Hi, yes in iOS I have mapView.trackingManager.start(chevron) and on android I have
tomtomMap.drivingSettings.startTracking(chevron) and the position of the chevron changes but the heading / bearing does not.

I can’t reproduce the issue. Can you try to reproduce it in our sample application(sampleapp-ktx) and post a code snippet here or create an issue on GitHub directly?

Code for Chevron tracking can be found in these classes:

Hello @Flyentology12 I managed to solve the issue. The problem was that I was not passing the bearing / heading to the matcher (it was always zero) and so the chevron faced the same direction all the time. My bad the issue is solved thanks for the help

1 Like