Question

I am trying to get the current position using the jquery-ui-map (getCurrentPoistion), but iIkeep getting this error:

Uncaught no such method 'getCurrentPosition' for gmap widget instance

This is my code:

var defaultLoc = new google.maps.LatLng(-0.9516469154747268, 30.269393920898438);
$('#map_canvas_dir').gmap({ 'center': defaultLoc, 'zoom':10});
$('#submit').click( function() {
    $('#map_canvas_dir').gmap('getCurrentPosition', function(status, pos) {
        if (status === "OK") {
            var latLng = new google.maps.LatLng(pos.coords.latitude,
                                                pos.coords.longitude);
            $('#map_canvas_dir').gmap('option', 'center', latLng);
            addNewMarker( latLng, 'green' );            
        }
        else {
            console.log('shit! it failed again');
        }                    
    }, { timeout: 4000, enableHighAccuracy: true } );
});

How can I fix this?

Was it helpful?

Solution

As Andrew Leach mentioned, the getCurrentPosition is an extension of the plugin. Most likely you haven't included jquery-ui-map-extensions.js

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top