Hi there, i have a single map from my region, and i can make and show the route.
what i want:
- color ONLY the route, multiple colors, Green,Red, Yellow based in Traffic.
i know if i put the line :
" map.addTier(new tt.TrafficFlowTilesTier(flowConfig)); " they color ALL MAP, but i dont want it, i need paint ONLY the route.
thanks in advance.
It is possible, but the implementation have to be done on your side. You will have to use multiple layers for drawing one route and for the colors, you will have to check manually the traffic data either from the routing engine response (‘traffic’ section) or from the Flow Segment Data API.
I’m also interested in showing traffic level information on different colors in one route, but I cannot find any ‘traffic’ section in calculateRoute() answer apart from ‘travelTimeInSeconds’ and ‘trafficDelayInSeconds’.
Which traffic section are you refering to? According to Routing API, when setting computeTravelTimeFor=‘all’, it is possible to get some more traffic information, as e.g. ‘noTrafficTravelTimeInSeconds’. However, when setting this parameter in SDK, this information is not shown in summary section.
Moreover, is there any rule (if it is public, I don’t know it) to consider when a segment should be drawn as green, yellow, orange, etc? I was considering doing it when delay is a certain percentage of the travelTime, but not sure if this is realistic, and which levels should be considered for each color.
If there are any traffic incidents on your route, you should find some sort of traffic parameters in the response. Please take a look at the docs: https://developer.tomtom.com/routing-api/routing-api-documentation-routing/calculate-route.
There are no strict rules for colors I think.
For your use case, however, after you’ll have the route coordinates, the easiest way is to use Flow Segment Data API which I mentioned in my previous answer. But it still will be some development on your side like checking each segment of your route, getting responses, constructing a new geoJson layer (with multiple colors), and at the end - drawing it. But it’s doable. Good luck!
Let me know if you’ll have more questions.
I believe that
sectionType=traffic is what are you looking for.