Cordova geolocation plugin not working on android device -


i'm using cordova geolocation plugin. when run index.html on browser can see location on map. when run project on android device cant anything. see white page. i'm using android version kitkat. instruction https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/index.html link. tried way questions. doesnt work. how can solve problem?

<!doctype html> <html> <head>     <meta name="format-detection" content="telephone=no">     <meta name="msapplication-tap-highlight" content="no">     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">     <script src="https://maps.googleapis.com/maps/api/js?key=aizasyc-id_zlczqktymwi2xrrmulxygozcuyhk"></script> </head> <body>     <div id="map" style="width:500px;height:500px;">     </div>     <script>         var latitude = undefined;         var longitude = undefined;         // geo coordinates         function getmaplocation() {             navigator.geolocation.getcurrentposition             (onmapsuccess, onmaperror, { enablehighaccuracy: true });         }         // success callback geo coordinates         var onmapsuccess = function (position) {             latitude = position.coords.latitude;             longitude = position.coords.longitude;             getmap(latitude, longitude);         }         // map using coordinates         function getmap(latitude, longitude) {             var mapoptions = {                 center: new google.maps.latlng(0, 0),                 zoom: 1,                 maptypeid: google.maps.maptypeid.roadmap             };             map = new google.maps.map             (document.getelementbyid("map"), mapoptions);             var latlong = new google.maps.latlng(latitude, longitude);             var marker = new google.maps.marker({                 position: latlong             });             marker.setmap(map);             map.setzoom(15);             map.setcenter(marker.getposition());         }         // success callback watching changing position         var onmapwatchsuccess = function (position) {             var updatedlatitude = position.coords.latitude;             var updatedlongitude = position.coords.longitude;             if (updatedlatitude != latitude && updatedlongitude != longitude) {                 latitude = updatedlatitude;                 longitude = updatedlongitude;                 getmap(updatedlatitude, updatedlongitude);             }         }         // error callback         function onmaperror(error) {             console.log('code: ' + error.code + '\n' +                 'message: ' + error.message + '\n');         }         // watch changing position         function watchmapposition() {             return navigator.geolocation.watchposition             (onmapwatchsuccess, onmaperror, { enablehighaccuracy: true });         }                getmaplocation();     </script>     <script type="text/javascript" src="cordova.js"></script>     <script type="text/javascript" src="js/index.js"></script>       </body> </html> 

İt androidmanifest.xml

<?xml version='1.0' encoding='utf-8'?> <manifest android:hardwareaccelerated="true" android:versioncode="10000" android:versionname="1.0.0" package="com.example.geo" xmlns:android="http://schemas.android.com/apk/res/android"> <supports-screens android:anydensity="true" android:largescreens="true" android:normalscreens="true" android:resizeable="true" android:smallscreens="true" android:xlargescreens="true" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.access_location_extra_commands" /> <application android:hardwareaccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsrtl="true">     <activity android:configchanges="orientation|keyboardhidden|keyboard|screensize|locale" android:label="@string/activity_name" android:launchmode="singletop" android:name="mainactivity" android:theme="@android:style/theme.devicedefault.noactionbar" android:windowsoftinputmode="adjustresize">         <intent-filter android:label="@string/launcher_name">             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application> <uses-sdk android:minsdkversion="16" android:targetsdkversion="24" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-feature android:name="android.hardware.location.gps" /> </manifest> 

add cordova js before googlemap api js

<script src="cordova.js"></script> 

and call function getmaplocation(); either deviceready or documentready function like

//deviceready document.addeventlistener("deviceready", getmaplocation, false);   //documentready $(document).ready(function(){     getmaplocation(); }); 

this you.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -