javascript - HTML5 geolocation - not working on Android -
the project i'm working on uses smartphones android (can't tell version it's recent) find user's current position. however, @ moment, brings "share current position" allow/reject question, nothing. if leave on page in background reloads after bit, , if allow reloads in case. should bring location in message prompt.
i point out works on iphone i've had access to, , in ie10 (i think is).
<asp:button id="btnlocate" text="loc" onclientclick="return getlocation()" runat="server" /> <script type="text/javascript"> function getlocation() { if (navigator.geolocation) { navigator.geolocation.getcurrentposition(showposition, showerror, { enablehighaccuracy: true, timeout: 31000, maximumage: 90000 }); } else{alert("geolocation not supported browser.");} } function showposition(position) { alert(position.coords.latitude + "," + position.coords.longitude); return false; } function showerror(error) { switch(error.code) { case error.permission_denied: alert("user denied request geolocation."); break; case error.position_unavailable: alert("location information unavailable."); break; case error.timeout: alert("the request user location timed out."); break; case error.unknown_error: alert("an unknown error occurred."); break; } } </script>
i should mention gps enabled , google maps able find location just-about instantly.
the issue code button acting form submit action. though browser paused prompt ok, out of way form submission fired. adding return false end of handler should correct (basically saying, "dont submit form"). don't know asp.net may not exactly.
Comments
Post a Comment