javascript - geolocation working on web browser but not on android phone browser -
I have a button with a button, when an alert with the clicked latitude and longitude shows it on Chrome on my laptop. Works, but when I try with my Android mobile, the page is showing, but there is no warning. I have tried to change the meeting in the current situation, but there is no change.
In an attempt to resolve this, I have placed a warning checkpoint and I have found that the function success () is being called in a laptop browser, but not the browser in the Android, the function error () is also not being called Please help please.
& lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Geolocation & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body onload = "getLocation ();" & Gt; & Lt; Input type = "button" id = "btn search" value = "search" onclick = "btn_Click ();" /> & Lt; Script & gt; Var Paus; Function btn_Click () {warning ("warning"); // Alert ('Lat:' + pos.coords.latitude + '' + 'Lawn:' + pos.coords.longitude); } GetLocation function (warning ("doSomething"); If (navigator. Geolocation) {warning ("Navigator. Location"); Navigator.geolocation.getCurrentPosition (success, error, options); Function success (status) {warning ("success"); Condition = condition; } Function error (mistake) {warning ("error"); }; Var option = {enableHighAccuracy: true, timeout: 5000, maximate: 0}; } And {warnings ("I'm sorry, but geolocation services are not supported by your browser."); }} & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt; I have also tried Google Gears, now GPS sign up is coming to Android but this location is still not showing ....
& lt; Html & gt; & Lt; Head & gt; & Lt; Title & gt; JavaScript Geo Sample & lt; / Title & gt; & Lt; Script src = "geo-min.js" type = "text / javascript" charset = "utf-8" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; B & gt; JavaScript Geo Sample & lt; / B & gt; & Lt; Script & gt; Var Paus; If (geo_position_js.init ()) {geo_position_js.watchPosition (success_callback, error_callback, {enableHighAccuracy: true}); } And {warnings ("functionality is not available"); } Function_c_allback (p) {pos = p; Warning ('lat =' + p.coords.latitude.toFixed (2) + '; lon =' + p.coords.longitude.toFixed (2)); } Function error_callback (p) {warning ('error =' + p.message); } ChangeLabel function () {document.getElementById ("Label1"). InnerHTML = pos.coords.latitude; } & Lt; / Script & gt; & Lt; ASP: labeled id = "label 1" runat = "server" text = "label" & gt; & Lt; / Asp: label & gt; & Lt; Br / & gt; & Lt; Input type = "button" id = "button1" value = "button" onclick = "ChangeLabel ()" /> & Lt; / Body & gt; & Lt; / Html & gt;
Your code is working perfectly.
Geo-location to work on an Android OS, you need to give some permissions in the Android Manifest.xm file, i.e.:
Permissions Usage: -
ACCESS_LOCATION_EXTRA_COMMANDS ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION If you want the geo-location functionality to work on all Android versions, you also need to add:
WRITE_EXTERNAL_STORAGE
Comments
Post a Comment