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: https://developer.tomtom.com/maps-sdk-web-js/tutorials-use-cases/taxi-cars-dispatcher
Or do you need to create one route thru all these points?

i want to show you my code angular with tomtom :
this.mapservice.getSupport().subscribe(data=>{

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

    this.mapservice.getXYPoste().subscribe(data=>{

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

        

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

        v.Y ==this.map.on('click',(e:any)=>e.lngLat.lat) || w.Y == this.map.on('click',(e:any)=>e.lngLat.lat))

        {

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

        

         this.map.addLayer({

          'id':this.map,

          'type': 'line',

          'source': {

            'type': 'geojson',

            'data': {

              'type': 'FeatureCollection',

              'features': [

                {

                  'type': 'Feature',

                  'geometry':{

                    '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.

2 Likes

exactly that is what i want to say