I am using Mapbox, Leaflet. Via Mapbox Walking directions I create directions and save origin and destination markers coordinates; Then I want to show this created direction. So I do following:

        var start = JSON.parse($('#start_field').val());
        var finish = JSON.parse($('#finish_field').val());
        L.mapbox.accessToken = 'qwerty';
        var map = L.mapbox.map('map', 'mapbox.streets', {
            zoomControl: false
        }).setView([42.8580536, 74.6224754], 12);
            waypoints: [
                L.latLng(start.lat, start.lng),
                L.latLng(finish.lat, finish.lng)

        var start_marker = L.marker([start.lat, start.lng], {
            draggable: false

        var finish_marker = L.marker([finish.lat, finish.lng], {
            draggable: false

But I have an error:

Uncaught TypeError: Cannot read property 'control' of undefined

| improve this question | | | | |
  • Are you hosting this on github? Can you share a link to your project page? – raphael Nov 25 '15 at 1:54

Somehow L.Routing doesn't exist. Are you using Leaflet Routing Machine? Make sure you're loading the script: <script src="leaflet-routing-machine.js">.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.