how to get directions using Google map v3 plugin for jQuery and jQuery Mobile?

941 views Asked by At

i am trying to get directions on a existing map. The documentation leaded me to this:

function getDirections()
{
    console.log('get directions');
    var map = $('#map');
    map.gmap().bind('init', function(evt, m) {
        map.gmap('displayDirections', { // error is here
            'origin': 'Los Angeles, USA',
            'destination': 'New York, USA',
            'travelMode': google.maps.DirectionsTravelMode.DRIVING
        }, {
            'map': map
        }, function(result, status) {
            if ( status === 'OK' ) {
                alert('Results found!');
            }
        });
    });
}

but this doesn't seem to do anything. I get an error Uncaught Error: Invalid value for property <map>: [object Object].

my objective is to load a map and click a button to show some directions.

any ideas?

1

There are 1 answers

1
Alkis Kalogeris On BEST ANSWER

You need to pass a javascript element. Not a jquery element. Try

'map': map[0]