Tdcreats
Tdcreats

Reputation: 11

How to change language of leaflet routing machine

I have leaflet routing machine local and i fixed the language mapbox issue

L.Routing.control({

  router: new  L.Routing.mapbox('map-key',{
                     language: 'nl',
                 }),

  waypoints:coordinates,
  routeWhileDragging: true,

  createMarker: function(i, wp, nWps) {

  return L.marker(wp.latLng, {icon: greenIcon });

}

Upvotes: 1

Views: 1187

Answers (1)

Soukaina EL HAYOUNI
Soukaina EL HAYOUNI

Reputation: 391

Try to add localization.js to your other scripts in angular.json file, like that:

"scripts": [
              "node_modules/leaflet-routing-machine/src/localization.js" 
            ]

then,

L.Routing.control({
/....// <-- your others option
  language: 'nl', // <-- for langage use just this

// you don't need to add formatter
  formatter:  new L.Routing.Formatter({
    language: 'nl'
  }),

}).addTo(map);

Upvotes: 2

Related Questions