javascript - navigator.geolocation in webview of android 4.4.2 returning undefined -
javascript - navigator.geolocation in webview of android 4.4.2 returning undefined -
i trying load current location in webview.
but navigator.geolocation returning undefined? same navigator.online?
is navigator object not supported in webview of android?
how current device location?
i using window.navigator.online
giving me true when connect net else gives false;
and dont forget add together config.xml
<feature name="networkstatus" > <param name="android-package" value="org.apache.cordova.networkmanager" /> </feature>
androidmanifest.xml
<uses-permission android:name="android.permission.access_network_state" />
to currentlocation:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script type="text/javascript" charset="utf-8"> document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready(){ navigator.geolocation.getcurrentposition(onsuccess, onerror, { maximumage : 3000, timeout : 5000, enablehighaccuracy : true }); } var address; function onsuccess(position) { var reversegeocoder = new google.maps.geocoder(); var currentposition = new google.maps.latlng(position.coords.latitude, position.coords.longitude); reversegeocoder.geocode({ 'latlng' : currentposition }, function(results, status) { if (status == google.maps.geocoderstatus.ok) { if (results[0]) { address= results[0].formatted_address; }else{ addess='address not found'; } } }); } // onerror callback receives positionerror object // function onerror(error) { //alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); } console.log(address); </script>
add config.xml
<feature name="geolocation" > <param name="android-package" value="org.apache.cordova.geobroker" /> </feature>
add androidmanifest.xml
javascript android html5 google-maps android-webview
Comments
Post a Comment