我需要在使用OSRM传单路由机时设置自己的OSRM服务器以显示在DB上保存的坐标?
好的,所以在我的Angular应用程序中,我正在在前端工作,我有两个下拉列表,在其中指定了出发城和到达市,后端使用了一个API来计算这两个输入的坐标,并使用传单和OpenStreet Map保存它们,我是我。能够将我在DB中存储的内容显示为一条直线,这并不是很漂亮,因此要寻找一种显示它们的方式,我发现了我发现OSRM传单式路由机,这很棒线/路径控制台显示此在此处 exter Image Descrigtion ,而在搜索时我被许多其他人发现了您必须设置自己的“设置OSRM的实例”,但是我真的需要这样做只是为了显示SNADED以读取行吗?还是有更方便的方法?这是我为演示服务器使用的代码,我猜这是我恐怕在给定时刻停止工作的代码:
L.Routing.control({
router: L.Routing.osrmv1({
serviceUrl: `http://router.project-osrm.org/route/v1/`
}),
plan: L.Routing.plan(waypoints, {
createMarker: (i, wp) => {
return L.marker(wp.latLng, {
draggable: false
});
}
}),
waypoints: waypoints,
routeWhileDragging: false,
addWaypoints : false, //disable adding new waypoints to the existing path
show: false,
}).addTo(this.map);
Ok so in my angular app I am working on the frontend I have two dropdown in which I specify the city of departure and arrival and the backend uses an api that calculates the coordinates of this two inputs and saves them using leaflet and openstreet map I was able to display what I have stored in DB as a straight line which was not pretty so searching for a way to display them snapped to road I found OSRM leaflet-routing-machine which works great but every time I go to my component for visualizing my lines/paths the console shows this enter image description here and while searching I found out by many others that you have to set up you own "set up instance of OSRM" but do I really need to do that just for displaying snaped to read lines ? Or is there a more convenient way? This is the code I am using for the demos servers I guess which I'm afraid will stop working at a given moment:
L.Routing.control({
router: L.Routing.osrmv1({
serviceUrl: `http://router.project-osrm.org/route/v1/`
}),
plan: L.Routing.plan(waypoints, {
createMarker: (i, wp) => {
return L.marker(wp.latLng, {
draggable: false
});
}
}),
waypoints: waypoints,
routeWhileDragging: false,
addWaypoints : false, //disable adding new waypoints to the existing path
show: false,
}).addTo(this.map);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于谁/谁是哪种正确的使用方法,一直在努力寻找适当的方法来安装OSRM在您的机器/PC/服务器中,我将使用该链接来帮助我在PC上安装它(Windows(Windows) 11 OS)并成功使用它而无需在控制台上显示警告:
https://phabi.ch/2020/05/06/run-osrm-in-docker-on-windows/
附带注意您需要在PC上安装Docker Desktop对于Docker桌面和上面的链接所示:将路径添加到系统环境的路径变量中。希望这对我有帮助。
To whoever/whomever which one is the correct way to use has been struggling with finding an appropriate way to install an instance of OSRM in you machine/pc/server I will refer with the link that helped me out installing it on my pc(windows 11 OS) and successfully using it without displaying the warning on the console:
https://phabi.ch/2020/05/06/run-osrm-in-docker-on-windows/
side note you need to have Docker Desktop installed on you pc make the right configuration to docker desktop and as the link above suggests: Add the path to the docker binary to your system environment’s path variable. Hope this helps it sure helped me.