Show route line

i want when i click at the marker , it show me the route line betwwen this marker and other coordinates that i get from database , i try to do this but i couldn’t .

That sounds similar to our taxi car dispatcher tutorial app:
Or do you need to create one route thru all these points?

i want to show you my code angular with tomtom :

  for( let v of(Object.values(data))){


      for( let w of(Object.values(data))){


        if(v.X =='click',(e:any)=>e.lngLat.lng) || w.X =='click',(e:any)=>e.lngLat.lng) ||

        v.Y'click',(e:any)=> || w.Y =='click',(e:any)=>


        if(v.code_dep == w.code_dep){



          'type': 'line',

          'source': {

            'type': 'geojson',

            'data': {

              'type': 'FeatureCollection',

              'features': [


                  'type': 'Feature',


                    'type': 'LineString',

                    'properties': {},

                    'coordinates': [[[v.X, v.Y],[w.X, w.Y]]]







          'layout': {

            'line-cap': 'round',

            'line-join': 'round'


          'paint': {

            'line-color': '#ff0000',

            'line-width': 9










Map.on() returns Map so I’m not sure if this is what you want to compare in the if statement.

1 Like

ahh , yeah i want in juste one click at the marker , show the line between the other marker that have the same value at a collmun.
exemple: if i click at a marker then a line will appear between the clicked marker and the other marker that have the same code which i get from my database ,

So I believe that in one listener you need to loop thru your data and then show a line based on defined conditions.


exactly that is what i want to say