osrm.js

2019-07-14 admin

osrm.js是什么

什么是osrm.js,REST client for the OSRM server API

osrm.js使用教程帮助文档

osrm.js

Build Status

Client library for Open Source Routing Machine - OSRM that uses the REST http API that is exposed by osrm-routed.

The interface is compatible with node-osrm. However it is not meant as replacement for node-osrm on the server.

Can be used with NodeJS and with browserify.

Example

var OSRM = require('osrm.js');

var osrm = new OSRM("https://router.project-osrm.org");

osrm.route({
      coordinates: [[13.438640,52.519930], [13.415852,52.513191]],
      steps: true,
      alternatives: false,
      overview: 'simplified',
      geometries: 'polyline'
   }, function(err, result) {
   console.log(result);
});

osrm.trip({
      coordinates: [[13.438640,52.519930], [13.415852,52.513191]],
      steps: true,
      overview: 'simplified',
      geometries: 'polyline'
   }, function(err, result) {
   console.log(result);
});

osrm.match({
      coordinates: [[13.438640,52.519930], [13.415852,52.513191]],
      timestamps: [1460585940, 1460585945],
      steps: true,
      overview: 'simplified',
      geometries: 'polyline'
   }, function(err, result) {
   console.log(result);
});

osrm.table({
      coordinates: [[13.438640,52.519930], [13.415852,52.513191], [13.333086, 52.4224]],
      sources: [0],
      destinations: [1, 2]
   }, function(err, result) {
   console.log(result);
});

osrm.tile([17603, 10747, 15], function(err, result) {
   console.log(result); // pbf encoded vector tile
});

//You can also pass it query paths directly:

osrm.request('/route/v1/driving/13.438640,52.519930;13.415852,52.513191', function(err, result) {
});

Testing

npm test # run node tape tests
firefox test.html # check the console if tape tests worked

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69738.html

文章标题:osrm.js

回到顶部