Reputation: 31
I want to retrieve the total road distance of a route between 2 locations using a TomTom map (Leaflet) and show it underneath the map... Does anyone have a working example of that?
My code so far is:
<script>
tomtom.setProductInfo('GeoDE', '4.44.7');
var map = tomtom.map('map', {
key: 'myKey'
});
tomtom.routingKey('myKey');
tomtom.routing({
traffic: false
})
.locations('48.78270899,9.182864184:47.78270899,8.182864184')
.go().then(function(routeJson) {
var route = tomtom.L.geoJson(routeJson, {
style: {color: '#0000ff', opacity: 0.6}
}).addTo(map);
map.fitBounds(route.getBounds(), {padding: [10, 10]});
});
</script>
Upvotes: 0
Views: 275
Reputation: 644
routeJson contains details of what you need: lengthInMeters and TravelTimeInSeconds
Upvotes: 1