我正在使用这个plugin ,我想将语言设置为法语 fr,为此我使用 formatter: new L.Routing.Formatter(language: 'fr')
就像你可以看到下面的代码:
L.Routing.control({
waypoints: [L.latLng(48.8534, 2.3488), L.latLng(44.837789, -0.57918)],
routeWhileDragging: true,
show: true,
formatter: new L.Routing.Formatter({ units: 'metric', language: 'fr' }),
autoRoute: true
}).addTo(this.mapInstance);
但是,result始终为英语“en”。
最佳答案
尝试使用这个:
- 首先,将 localization.js 添加到 angular.json 文件中的其他脚本中,如下所示:
"scripts": [
"node_modules/leaflet-routing-machine/src/localization.js"
]
- 然后,将选项语言:'fr'添加到您的路由控件中,如下所示:
L.Routing.control({
waypoints: [
L.latLng(57.74, 11.94),
L.latLng(57.6792, 11.949)
],
collapsible: true, // hide/show panel routing
autoRoute: true, // possibility to take autoRoute
language : 'fr', // < --- THIS IS ESPECIALLY WHAT YOU SHOULD ADD
// ...
}).addTo(this.map);
关于leaflet - 传单路由机上的语言未切换为法语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58305824/