0

我正在尝试使用 jquery-ui-map (getCurrentPoistion) 获取当前位置,但 iIkeep 收到此错误:

未捕获 gmap 小部件实例的此类方法“getCurrentPosition”

这是我的代码:

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 } );
});

我怎样才能解决这个问题?

4

1 回答 1

1

正如 Andrew Leach 提到的,getCurrentPosition 是插件的扩展。很可能您没有包含 jquery-ui-map-extensions.js

于 2012-05-18T20:23:40.270 回答