Sorry, you need to enable JavaScript to visit this website.

Map Driving Extension

Map Driving Extension

This module is built on top of Maps SDK for Android and contains logic and helpful utils that can
be used in more complex scenarios, like driving or cycling.

To use this library, add the following dependency to the build.gradle file:

implementation("com.tomtom.online:sdk-maps-driving-extensions:2.4207")
Map and route matching

Map matching snaps inaccurate GPS probe to the road network obtained from map tiles so roads are
represented by collections of coordinates. Route matching is a special case of map matching which
snaps inaccurate GPS probe to the given route. The reference route is represented by a collection
of coordinates. The route can be calculated using the Routing API or provided manually.

Sample use case: You have a speed radar application that is used when driving. To have a proper
user experience, you want to match GPS positions with the road data obtained from map tiles.

Sample use case: You want to match/place the chevron with the the right road.

Sample use case: A user plans and displays a route on the map in your app. The vehicle position
is being matched along the planned route.

To create map matcher instance and register for updates:

_

matcher = MatcherFactory.createMatcher(tomtomMap.asMatchingDataProvider());
matcher.setMatcherListener(new ChevronMatcherUpdater(getChevron(), tomtomMap));
matcher = MatcherFactory.createMatcher(matchingDataProvider)
matcher.setMatcherListener(this)

To create route matcher instance and register for updates:

_

matcher = MatcherFactory.createMatcher(LatLngTraceMatchingDataProvider.fromPoints(getFirstRouteFromMap()));
matcher.setMatcherListener(new ChevronMatcherUpdater(getChevron(), tomtomMap));
matcher = MatcherFactory.createMatcher(matchingDataProvider)
matcher.setMatcherListener(this)

It is important to dispose matcher instance, once it is not going to be used. Otherwise memory leaks may occur:

_

matcher.dispose();
matcher.dispose()

To update map matcher with new GPS position:

_

matcher.match(location);
matcher.match(location)

To process map matcher results:

_

@Override
public void onMatched(MatchResult matchResult) {

    chevron.setDimmed(!matchResult.isMatched());
    chevron.setLocation(matchResult.getMatchedLocation());
    chevron.show();

    tomtomMap.getOverlaySettings().removeOverlays();
    tomtomMap.getOverlaySettings().addOverlay(
            CircleBuilder.create()
                    .position(new LatLng(matchResult.originalLocation))
                    .fill(GPS_DOT_FILL)
                    .color(GPS_DOT_COLOR)
                    .radius(GPS_DOT_RADIUS)
                    .build()
    );
}
chevron.isDimmed = it.isDimmed
chevron.setLocation(it.matchedLocation)
chevron.show()
showOriginalLocationDot(it)

Follow the chevron

Allow your users to follow their changing positions on the map e.g. when driving. When a new
location is set, the animation moves the chevron to the new position.

Sample use case 1: You want to show your user position when driving.

Custom chevron indicator

You can set a custom icon for the chevron indicator.

To create custom chevron:

_

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

Chevron tracking mode

Additionally, it is possible to track the chevron. It means that the camera/map and the chevron
move when a new location is received so that the map is always centered on the chevron with
the bearing of the drive. In the tracking mode, rotate and pan gestures are blocked.
The user can change only zoom level, while the map camera is automatically adjusted
to follow the chevron.

To start tracking selected chevron:

_

tomtomMap.getDrivingSettings().startTracking(getChevron());
tomtomMap.drivingSettings.startTracking(chevron)

To stop tracking selected chevron:

_

tomtomMap.getDrivingSettings().stopTracking();
tomtomMap.drivingSettings.stopTracking()


image

Chevron overview

image

Chevron tracking

You are here