0

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?

Mat
  • 202,337
  • 40
  • 393
  • 406
Mukiza Andrew
  • 763
  • 1
  • 8
  • 17
  • What are you trying to get the position of? If its the physical location of the user, try looking at navigator.geolocation: https://developer.mozilla.org/en/Using_geolocation – Oliver May 13 '12 at 09:02
  • There's no indication in the question that you've followed the documentation and implemented that method. It's not native to jquery-ui-map. http://code.google.com/p/jquery-ui-map/wiki/Examples#Example_get_user_position – Andrew Leach May 13 '12 at 09:16

1 Answers1

1

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