Keplerjs / keplerjs-openrouteservice

keplerjs plugin for OpenRouteService API
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

npm pkg openrouteservice-js #5

Closed stefanocudini closed 5 years ago

stefanocudini commented 6 years ago

asking support to @TimMcCauley for integrate client side ors api

https://github.com/GIScience/openrouteservice-js

TimMcCauley commented 6 years ago

@stefanocudini sure - can you help me understand how to proceed?

stefanocudini commented 6 years ago

I would like to support all the services you have published on the KeplerJs platform as they are very useful!

Referring to this issue https://github.com/GIScience/openrouteservice-js/issues/4

in the meantime I managed to make only the directions module work, but the other modules that connect to services

I think that at present the management of the modules is not commojs compatible and therefore can not be easily included in a nodejs project like this

it should be possible to expose all modules simply by including an index.js file in the repository root (specified in the main: in package.json field) without having to know the path of the files to be included.

stefanocudini commented 6 years ago

in this specific case, I am forced to specify the complete path:

server/Ors.js#L7

var baseDir = 'openrouteservice-js/src/';
var Directions = Npm.require(baseDir+'OrsDirections');

but the standard behaviour should be this:

var OrsJs = Npm.require('openrouteservice-js');

and the other modules should be accessible with this OrsJs object

TimMcCauley commented 6 years ago

@stefanocudini could you please try version 0.0.2 ?

const Ors = require('openrouteservice-js')

var Directions = new Ors.Directions({
  api_key: "XY"
});

Directions.calculate({
  coordinates: [[8.690958, 49.404662], [8.687868, 49.390139]],
  profile: "driving-car",
  extra_info: ["waytype", "steepness"],
  geometry_format:"encodedpolyline",
  format: "json",
  mime_type: "application/json"
})
  .then(function(response) {
    console.log("response", response);
  })
  .catch(function(err) {
    var str = "An error occured: " + err;
    console.log(str);
  });
stefanocudini commented 5 years ago

many tnks @TimMcCauley from the Kepler version 1.6.2 this plugin import the module v0.0.2 and all works well. https://github.com/Keplerjs/keplerjs-openrouteservice/blob/master/package.js#L11

TimMcCauley commented 5 years ago

@stefanocudini you are welcome and thank you for using ors!!

stefanocudini commented 5 years ago

in version 0.0.9 mi import works.. but I have other issue with geojson format, look here: https://github.com/GIScience/openrouteservice-js/issues/13