html5 - HTML 5 geolocation POSITION UNAVAILABLE error in mobile -


i trying user current position in mobile web application app work in android telephone device except samsung galaksy s2 telephone device .. give errror position unavailable error
demo link.you can view source code

navigator.geolocation.getcurrentposition(handle_geolocation_query1, handle_errors) ;        function handle_errors(error) {             switch (error.code) {                     case error.permission_denied: alert("user did not share geolocation data");                         break;                     case error.position_unavailable: alert("could not detect current position");                         break;                     case error.timeout: alert("retrieving position timed out");                         break;                     default: alert("unknown error");                         break;                 }             }         function handle_geolocation_query1(position) {                   $('#map_canvas').gmap('addmarker', {                      'id':'m_1',                     'position': new google.maps.latlng(position.coords.latitude,position.coords.longitude),                     'bounds': true,                     'icon': 'http://google-maps-utility-library-v3.googlecode.com/svn/trunk/geolocationmarker/images/gpsloc.png'                 }).click(function () {            $('#map_canvas').gmap('openinfowindow',{ 'content': '<font color="#2a2a2a" size="4">location </font><br/><font color="#4a4a4a">your current location</font>' }, this);                 });                  var map = $('#map_canvas').gmap('get', 'map');                 map.setzoom(14);                 map.setcenter(new google.maps.latlng(41.01802007732287, 28.971880674362183));                 map.setmaptypeid(google.maps.maptypeid.roadmap);                } 

edited: used phonegap produce android apk file when work apk file application give error position unavailable error when call page web works not give error ... web link , can download apk here

your code working fine in browser not in mobile.

on checking source code seems you're specifying sensor parameter false.

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 

you missed while checking documentation.

specifying sensor parameter

use of google maps api requires indicate whether application using sensor (such gps locator) determine user's location. especially important mobile devices. applications must pass required sensor parameter tag when including maps api javascript code, indicating whether or not application using sensor device.

applications determine user's location via sensor must pass sensor=true when loading maps api javascript.

hope understand.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -