Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-14214

Takes 6 to 15 seconds when calling getCurrentPosition in Android

VotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Won't Fix
    • None
    • None
    • None
    • Cordova version : 8.0.0

       

    Description

      Location is turned on the phone.It takes 5 to 20 seconds when getCurrentPosition method is called. 

      Code : 

      var app = {
      // Application Constructor
      initialize: function()

      { document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); }

      ,

      // deviceready Event Handler
      //
      // Bind any cordova events here. Common events are:
      // 'pause', 'resume', etc.
      onDeviceReady: function()

      { this.receivedEvent('deviceready'); }

      ,

      // Update DOM on a Received Event
      receivedEvent: function(id)

      { var parentElement = document.getElementById(id); var listeningElement = parentElement.querySelector('.listening'); var receivedElement = parentElement.querySelector('.received'); listeningElement.setAttribute('style', 'display:none;'); receivedElement.setAttribute('style', 'display:block;'); console.log('Received Event: ' + id); navigator.geolocation.getCurrentPosition(onSuccess, onError); }

      };
      var onSuccess = function(position)

      { alert('Latitude: ' + position.coords.latitude + '\n' + 'Longitude: ' + position.coords.longitude + '\n' + 'Altitude: ' + position.coords.altitude + '\n' + 'Accuracy: ' + position.coords.accuracy + '\n' + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' + 'Heading: ' + position.coords.heading + '\n' + 'Speed: ' + position.coords.speed + '\n' + 'Timestamp: ' + position.timestamp + '\n'); }

      ;

      // onError Callback receives a PositionError object
      //
      function onError(error)

      { alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); }

      app.initialize();

      Attachments

        1. app-debug.apk
          1.63 MB
          Sriram Kalyanasundaram
        2. source.zip
          28 kB
          Sriram Kalyanasundaram

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            sriram6781 Sriram Kalyanasundaram
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment