I am using ‘jquery-ui-map’ for an android app. My emulator is Google API Level 13 version 3.2. My Javascript code is :
$('#gps_map').live("pageshow", function() {
$('#map_canvas_2').gmap('refresh');
$('#map_canvas_2').gmap('getCurrentPosition', function(position, status) {
if ( status === 'OK' ) {
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
$('#map_canvas_2').gmap('get', 'map').panTo(latlng);
$('#map_canvas_2').gmap('search', { 'location': latlng }, function(results, status) {
if ( status === 'OK' ) {
$('#from').val(results[0].formatted_address);
}
});
} else {
alert('Unable to get current position');
}
});});
This code always fails to get location. I can’t see the GPS icon in the emulator. I tried setting all possible permissions, tried setting the latlong coordinates with geo fix method but nothing works. Is there ANY way by which geo location can work on android ?
Finally found the answer to this.
Adding a longer timout in options, like shown above fixes the issue. The example shows a long timeout: 10 seconds.