Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The plugin doesn't work #2

Open
alexolliveira opened this issue Jul 19, 2019 · 6 comments
Open

The plugin doesn't work #2

alexolliveira opened this issue Jul 19, 2019 · 6 comments

Comments

@alexolliveira
Copy link

The plugin doesn't work in 2019. Help me!!!

@mrohnstock
Copy link
Owner

I'm still using it in production, can't find any issues. Whats the problem you see (console output or something...)?

@Restyle5
Copy link

How to use the plugin? I'm lost here

@mrohnstock
Copy link
Owner

This is a plugin for Leaflet + Leaflet Routing Machine, so you need to have setup Leaflet and Leaflet Routing Machine at least to be able to use this plugin, without them, it won't work.

After setup you'll need an account for TomTom Developer Portal, where you fetch your API-Key to access the service of TomTom. After that, just follow the usage from the readme.

@Restyle5
Copy link

like this? (I have the tomtom key)

<script src="http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.js"></script> <script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"></script> <script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
<script>
	var L = require('leaflet');
	require('leaflet-routing-machine');
	require('lrm-tomtom'); // This will tack on the class to the L.Routing namespace

	L.Routing.control({
	    router: new L.Routing.TomTom('<My key>', options),
	}).addTo(map);

</script>

Error : [options is not defined], [require is not defined], [L.Routing.TomTom is not a construct]
I do able to download lrm-tomtom but not sure which script did you want me to include. (Im a beginner, sorry)

@mrohnstock
Copy link
Owner

mrohnstock commented Sep 21, 2021

well, as you'll need to build this project to be able to use it in webbrowser, I already made a shim repository, where I already made this step:

https://github.com/mrohnstock/leaflet-routing-machine

A sample would be something like this:

<html>
<head>
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css" />
  <link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.css" />
  <script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"></script>
  <script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
  <script src="https://raw.githubusercontent.com/mrohnstock/leaflet-routing-machine/master/js/lrm-tomtom.js">
  <script>
    var options = { language : 'en-US' }; // see usage for available options
  
    var map = L.map('mapid').setView([51.505, -0.09], 13);

    L.Routing.control({
      router: new L.Routing.TomTom('<My key>', options),
    }).addTo(map);
  </script>
  <style>
    #mapid { height: 180px; }
  </style>
</head>
<body>
  <div id="mapid"></div>
</body>
</html>

Have not tested this sample, but I guess you should get the drill...

Working samples for Leaflet-Routing-Machine could be found on the following page:

https://www.liedman.net/leaflet-routing-machine/tutorials/basic-usage/

@Restyle5
Copy link

I do believe my problem is not knowing where/how to get lrm-tomtom.js, after a few small adjustment, the code you wrote is working. Thank you so much..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants