willmorejg / lrm-openrouteservice

Leaflet Routing Machine - OpenRoute Service extension
Apache License 2.0
18 stars 16 forks source link

ERROR TypeError: L.Routing.openrouteservice is not a constructor #4

Open fahmisaad opened 5 years ago

fahmisaad commented 5 years ago

Hi,

i try using your library into my project which is using ionic framewrok. but i got this error

ERROR TypeError: L.Routing.openrouteservice is not a constructor

when i run the app. i already include your library into my project and i can confirm that the location of the library can be access by the project. May i know how to solve this issue? already stuck at this issue nearly 3 days. Below are my code: ` this.mymap = L.map("mapid").setView([3.101984, 101.598002], 13);

L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  attribution: '© OpenStreetMap contributors and ORS'
}).addTo(this.mymap);

var control = L.Routing.control({
  waypoints: [
    L.latLng(3.102739, 101.598077),
    L.latLng(3.101861, 101.599037)
  ],
  router: new L.Routing.openrouteservice('5b3ce3597851110001cf6248e3cd48b3c44c4e529f8fac67408d4257')
  // routeWhileDragging: true
}).addTo(this.mymap);` 

Thanks.

fapdash commented 5 years ago

The error message shows up when the library hasn't been loaded.

I don't know how you handle dependencies in your project but I had this problem when I tried to include the library directly from GitHub (FF blocked the request because GH didn't send the proper MIME info or something). Once I saved the lib to disk and loaded it from there it worked.