Tomtom.routing();

I’m getting by ajax from mysql some coordinates, and i’m putting with js at:
tomtom.routing().locations(string).go().then(function(routeJson){
var route = tomtom.L.geoJson(routeJson, {style: {color: ‘#00d7ff’, opacity: 0.9, weight: 6}}).addTo(map); map.fitBounds(route.getBounds(), {padding: [5, 5]});
But doesnt running!
Error:
Uncaught TypeError: Routing location is expected. But [-25.43889,-49.27329]+’:’+[-25.42987,-49.27533]+’:’+[-25.4237386,-49.2696136]+’:’+[-25.435690,-49.287480] [string] given at Object.routingLocations. Help me!

Have you tried removing square brackets?

1 Like

Hi, the service expects something like this:
locations(‘52.3679,4.8786:52.3679,4.8798’)

Please make sure the string you pass to the SDK has the right format.

You can also have a look at this: https://developer.tomtom.com/maps-sdk-web/functional-examples#routing

Also, I see that you are using v4, you could give v5 a go!

2 Likes

Thanks! I resolved it