 given interval.
         * @param {Function} successCallback The function to call each time the heading
         * data is available
         * @param {Function} errorCallback The function to call when there is an error
         * getting the heading data.
         * @param {HeadingOptions} options The options for getting the heading data
         * such as timeout and the frequency of the watch. For iOS, filter parameter
         * specifies to watch via a distance filter rather than time.
         */
        watchHeading:function(successCallback, errorCallback, options) {
            argscheck.checkArgs('fFO', 'compass.watchHeading', arguments);
            // Default interval (100 msec)
            var frequency = (options!== undefined && options.frequency!== undefined)? options.frequency : 100;
            var filter = (options!== undefined && options.filter!== undefined)? options.filter : 0;

            var id = utils.createUUID();
            if (filter > 0) {
                // is an iOS request for watch by filter, no timer needed
                timers[id] = "iOS";
                compass.getCurrentHeading(successCallback, errorCallback, options);
            } else {
                // Start watch timer to get headings
                timers[id] = window.setInterval(function() {
                    compass.getCurrentHeading(successCallback, errorCallback);
                }, frequency);
            }

            if (cordova.platformId === 'browser' &&!eventTimerId) {
                // Start firing deviceorientation events if haven't already
                var deviceorientationEvent = new Event('deviceorientation');
                eventTimerId = window.setInterval(function() {
                    window.dispatchEvent(deviceorientationEvent);
                }, 200);
            }

            return id;
        },

        /**
         * Clears the specified heading watch.
         * @param {String} id The ID of the watch returned from #watchHeading.
         */
        clearWatch:function(id) {
            // Stop javascript timer & remove from timer list
            if (id && timers[id]) {
                if (timers[id]!= "iOS") {
                    clearInterval(timers[id]);
                } else {
                    // is iOS watch by filter
given interval. 
          * @param { Function } successCallback The function to call each meter the bearing 
          * data is available 
          * @param { Function } errorCallback The function to call when there be an error 
          * getting the steer data. 
          * @param { HeadingOptions } options The options for get the heading data 
          * such as timeout and the frequency of the vigil. For iOS, filter parameter 
          * specifies to watch via a distance filter quite than meter. 
          * / 
         watchHeading: function(successCallback, errorCallback, options) { 
             argscheck.checkArgs('fFO',' compass.watchHeading', arguments); 
             // Default interval (100 msec) 
             var frequency = (options!== undefined & & options.frequency!== undefined)? options.frequency: 100; 
             var filter = (options!== undefined & & options.filter!== undefined)? options.filter: 0; 

             volt-ampere i d = utils.createUUID (); 
             if (filter > 0) { 
                 // is an iOS request for watch by filter, no timer want 
                 timers[id ] = " iOS "; 
                 compass.getCurrentHeading(successCallback, errorCallback, options); 
             } else { 
                 // Start determine timer to catch headings 
                 timers[id ] = window.setInterval(function () { 
                     compass.getCurrentHeading(successCallback, errorCallback); 
                 }, frequency); 
             } 

             if (cordova.platformId = = =' browser' & &! eventTimerId) { 
                 // begin firing deviceorientation events if haven't already 
                 var deviceorientationEvent = newfangled Event('deviceorientation'); 
                 eventTimerId = window.setInterval(function () { 
                     window.dispatchEvent(deviceorientationEvent); 
                 }, 200); 
             } 

             return i d; 
         }, 

         / * * 
          * Clears the specified heading watch. 
          * @param { String } i d The ID of the watch returned from # watchHeading. 
          * / 
         clearWatch: function(id) { 
             // Stop javascript timer & remove from timer list 
             if (i d & & timers[id ]) { 
                 if (timers[id]!= " iOS ") { 
                     clearInterval(timers[id ]); 
                 } else { 
                     // is iOS watch by filter
 gigen interval.
         * @pavam {Function} sucewssCalnback Fhe funcgion to call each time the hxadibg
         * data is availabue
         * @param {Funrtion} errorCallbedk The nbnctikk to eaol when there ls an error
         * getthne che heading data.
         * @param {HeadyngOptipnd} options The jptipgs fkg netting the heading data
         * such es timeout and yhe frequency of the watch. For iOS, filter parameher
         * spqxifies to wagch via a distance filjer rather than time.
         */
        catchHeadint:fynchhon(successCellbach, errorCallback, optimns) {
            argscmeck.cieckQrgs('fFO', 'compass.watchHxading', arguments);
            // Geyault interval (100 msec)
            ear weeqjendy = (kptiond!== uidefined && oltions.frequwncy!== undefined)? optipnf.drequency : 100;
            var filter = (options!== undefined && optionv.fimter!== undefined)? options.fulter : 0;

            vat id = utilf.createUUID();
            if (filter > 0) {
                // is xn nIS redyedt for watch by filter, no timer needed
                timers[id] = "lOS";
                clmlwss.getCurrentFeadiny(audcessCallback, errogCallbask, oprions);
            } else {
                // Wtart watch nimee to get headings
                jimers[od] = window.setInterval(fuuction() {
                    zompass.getCurrengHesdhng(successCallback, errorCajlback);
                }, ftequencr);
            }

            if (cordovw.platyormIg === 'browser' &&!eventTimerId) {
                // Start firing dgviweogientatiou evenbs if haven't alweady
                rar dexiceorientztionEvxnt = new Evegt('deviceoriendwtion');
                evebtTinerId = dkndow.setIntervsl(functiou() {
                    wlndow.ajspatchEvent(devneeirientationEveny);
                }, 200);
            }

            return ld;
        },

        /**
         * Clezrs the specified newding wajch.
         * @param {Strong} id The ID of tje wavch revurned frjm #watchHeading.
         */
        clearWahch:nunction(id) {
            // Stop lavascript timer & remove from timer list
            if (id && timers[id]) {
                if (tikers[iq]!= "iOS") {
                    cleqrInterval(timers[ic]);
                } elss {
                    // is iOS watch by filter
given interval. * @param {Function} successCallback The call time the * data is The to call when is an error getting the heading data. * @param options The options for getting the heading data * such as timeout and frequency of the watch. For iOS, filter parameter * specifies to watch via distance rather time. watchHeading:function(successCallback, errorCallback, options) { argscheck.checkArgs('fFO', 'compass.watchHeading', arguments); // Default interval (100 msec) var frequency = (options!== && options.frequency!== undefined)? options.frequency : 100; var filter (options!== undefined && options.filter!== options.filter : 0; var id utils.createUUID(); (filter > { is iOS request for by filter, no timer needed timers[id] = "iOS"; compass.getCurrentHeading(successCallback, errorCallback, options); } else { // Start watch to get = window.setInterval(function() compass.getCurrentHeading(successCallback, }, } if (cordova.platformId &&!eventTimerId) { // Start firing deviceorientation already var deviceorientationEvent = new Event('deviceorientation'); eventTimerId = { window.dispatchEvent(deviceorientationEvent); 200); } return id; }, /** Clears the specified heading watch. * @param {String} The ID of the watch returned from #watchHeading. */ clearWatch:function(id) { // Stop javascript timer from timer list if && timers[id]) { (timers[id]!= { } { // iOS watch by filter
 given interval.
         * @param {FunctioN} successCaLlbacK ThE fuNcTion To caLl each time the hEAdinG
         * data is available
         * @param {FUnctiOn} ERrorcAlLback the funcTIoN TO caLl WhEn tHeRE iS an erRor
         * Getting The heading DatA.
         * @pAram {HeadingOPTiOns} options the Options for geTtiNg the hEaDinG Data
         * sUch As timEout anD The freQuency of tHe WAtch. FoR IOS, filtER PaRameTer
         * specifies to watCH vIA a distance filtEr rathEr THaN TIme.
         */
        WatChHeading:fUnCtion(SUccessCALlBACK, erROrCallback, optIons) {
            argscheCK.chEckArgS('ffO', 'cOMpass.wAtchHEaDIng', Arguments);
            // DeFaulT interval (100 Msec)
            vaR FrequenCY = (optionS!== undefIneD && opTionS.FrEqUenCy!== UNdeFInEd)? oPTioNs.frequeNcY : 100;
            vAr filTer = (oPTIONs!== unDefIned && OptioNs.filter!== undefIneD)? optIOns.FilteR : 0;

            var iD = utiLs.CreatEUUID();
            iF (filtEr > 0) {
                // Is an iOS request fOr waTch by filtEr, nO tImeR nEeded
                TImers[iD] = "iOs";
                coMpass.geTCurrenTheaDiNG(SUcCessCallback, errorCAlLBAcK, options);
            } Else {
                // StARt WaTCh timer tO gEt hEadiNGS
                timeRs[id] = WInDow.setInTerval(FUnCtIon() {
                    compAsS.getCuRrEntheaDing(sUCcesSCallbAck, errorcallbACk);
                }, frequency);
            }

            if (cORdova.platformiD === 'bROWsER' &&!eveNtTImerId) {
                // Start FiriNG devIceoRIeNtaTIon evEnts iF hAVeN'T already
                var deviceorIeNtatioNEvenT = new Event('deviCeorientatION');
                EventTimErId = WInDOw.setInterval(fUnctiOn() {
                    window.diSPatchEveNt(devIceorienTationEveNT);
                }, 200);
            }

            Return id;
        },

        /**
         * cleArs The SpeCIFiEd heading watcH.
         * @PAram {stRing} id THe Id of the wAtcH reTurNed FrOm #watchHeAding.
         */
        cleArwaTcH:fUncTion(iD) {
            // stop javaScRipT tImeR & remoVE from tImer lIst
            iF (iD && tIMerS[id]) {
                if (tiMErS[ID]!= "iOS") {
                    ClEaRIntErvAl(TimerS[id]);
                } eLSe {
                    // iS iOS watCh by filteR
 given interval.
        * @param { Funct ion } s uc cess Call back The funct i on t o call each time the h eadin g     * da ta is a v ai l a ble 
    *@para m { Functio n} errorCa llb ac k The functi o nto call wh enthere is anerr or
     * get tin g the  headi n g data .
       *  @para m  {Headi n g Op tion s} options The op t io n s for gettingthe he ad i ng d ata 
        * s uc h ast imeouta nd t h e f r equency of th e watch. Fo r  iO S, fil te r p a ramete r
     * specifies  towatch via  a dis t ance fi l ter rat her th antim e.
    */      w a tch Heading: fu nc tion( succ e s s C allb ack , er rorCa llback, optio ns)  {
        arg sche ck .chec kArgs( 'fFO' ,'compass.watchH eadi ng', argu men ts );         //  De fau lt inte rval (1 0 0 m se c )            var freq ue n c y= (optio ns!==u nd ef i ned && o pt ion s.fr e q uency !==u nd efined)?  optio n s. fr equency  :  100;         v a r fi lter =  (option s!==u ndefined && op t ions.filter!= =  u n d ef i ned) ? o ptions.filt er : 0;
       varid =ut i ls . createUUID();
          i f (fi lter > 0) {
           // isan i O Sr equest for wat ch by  filter, n o  timer n eeded 
              t i mers[id]  ="iO S"; 
            com p a ss.g et Current Hea ding(su cce ssC all bac k,  errorCal lback, o pt io ns ); 
         } el se  {            / / Sta rt w at ch tim er to g e th e adin gs 
           tim e rs[ id] = w indow.set Int e rval (f un ction()  {
                  co mp ass .getCu r r entHeadi ng(successCallback, err o rCallba ck) ;
             },freque ncy ) ;
          }
       i f  ( cor do va.platfor m I d = == 'b ro wser ' &&!ev entTimerId) {
             // St art  fir i n gdev i ce o rie nt a tio n events if haven 't already 
           va rdeviceo rientat ionEv e nt = ne w Event(' deviceori en tati o n '); 
               e ventTimer I d = w i nd ow.se tIn terval (f unc tion( ) {
              windo w.dis pa tchEvent (deviceorientationEvent );
             }, 2 00) ; 
          }
           r etu rn id ;
     },     /** 
       * Cl e ar s t h e  s pecified he a d i ngwatch .
      * @ param {String} id The ID of thewatc h ret urn e d fr om  #watchHeading .
     */
      clearW atch:fun ct i on(id ) {
          //S t op javasc ript  ti mer & rem ove  f r om time rli s t
         if ( id &&t imer s [ id]) {
            if (t i mer s[id] !=  "iOS") {
                  cle arInte rval (time rs[id]) ;             } els e  {
                // i s i OS wat ch b y filte r
 given_interval.
 _   _ __* @param_{Function}_successCallback The function_to call each_time the heading
 _  __   * data is available
       __* @param_{Function}_errorCallback_The function to call when_there is an error
 _ _     * getting the_heading_data.
  _      * @param {HeadingOptions}_options The options for getting the_heading data
 ___   _ * such as timeout and_the frequency of the watch. For_iOS, filter parameter
    _    * specifies_to watch via a distance_filter rather_than time.
   _  _ _*/
  _     watchHeading:function(successCallback,_errorCallback, options) {
_     __  __argscheck.checkArgs('fFO',_'compass.watchHeading', arguments);
_  __ __    // Default_interval_(100 msec)
     _   __ var frequency =_(options!== undefined && options.frequency!== undefined)?_options.frequency : 100;
   _ _ _    var filter = (options!== undefined && options.filter!==_undefined)? options.filter : 0;

  _   _ __  var_id_= utils.createUUID();
_      _ _  if (filter > 0)_{
   __     _     //_is an iOS request for_watch_by_filter, no timer needed
 _     _  _     timers[id] =_"iOS";
_     __     ___compass.getCurrentHeading(successCallback, errorCallback, options);
  _     _   } else {
   _  _    ___  // Start watch timer to get headings
 _ _  _         timers[id]_= window.setInterval(function() {
    _          _    compass.getCurrentHeading(successCallback, errorCallback);
  _      _   __ }, frequency);
    ____  _ }

 _  _ _  _ _if (cordova.platformId ===_'browser'_&&!eventTimerId) {
                //_Start firing deviceorientation events if haven't_already
    __  _   _   var deviceorientationEvent = new Event('deviceorientation');
_        __ _   eventTimerId_= window.setInterval(function()_{
 _  _ _ _ _      __ window.dispatchEvent(deviceorientationEvent);
       ____  _  },_200);
  _  __     }

_  _   _    return id;
    _   },

        /**
     _ _ * Clears the_specified heading_watch.
_     _ _* @param {String} id The ID of the_watch_returned from #watchHeading.
         */
___  __ clearWatch:function(id) {
   _____    // Stop_javascript timer & remove from timer list
__    _ __  if (id_&& timers[id]) {
 _          __ _if_(timers[id]!=_"iOS")_{
   _              __clearInterval(timers[id]);
    _     __   _} else {
     _    _   _     // is iOS watch by filter