久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      1. <legend id='wj1TO'><style id='wj1TO'><dir id='wj1TO'><q id='wj1TO'></q></dir></style></legend>

      2. <small id='wj1TO'></small><noframes id='wj1TO'>

        <i id='wj1TO'><tr id='wj1TO'><dt id='wj1TO'><q id='wj1TO'><span id='wj1TO'><b id='wj1TO'><form id='wj1TO'><ins id='wj1TO'></ins><ul id='wj1TO'></ul><sub id='wj1TO'></sub></form><legend id='wj1TO'></legend><bdo id='wj1TO'><pre id='wj1TO'><center id='wj1TO'></center></pre></bdo></b><th id='wj1TO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='wj1TO'><tfoot id='wj1TO'></tfoot><dl id='wj1TO'><fieldset id='wj1TO'></fieldset></dl></div>

        <tfoot id='wj1TO'></tfoot>
          <bdo id='wj1TO'></bdo><ul id='wj1TO'></ul>

        Cordova Geolocation 插件在 Android 上返回空位置對象

        Cordova Geolocation plugin returning empty position object on Android(Cordova Geolocation 插件在 Android 上返回空位置對象)
          <bdo id='tZKWO'></bdo><ul id='tZKWO'></ul>
              <tbody id='tZKWO'></tbody>
          • <i id='tZKWO'><tr id='tZKWO'><dt id='tZKWO'><q id='tZKWO'><span id='tZKWO'><b id='tZKWO'><form id='tZKWO'><ins id='tZKWO'></ins><ul id='tZKWO'></ul><sub id='tZKWO'></sub></form><legend id='tZKWO'></legend><bdo id='tZKWO'><pre id='tZKWO'><center id='tZKWO'></center></pre></bdo></b><th id='tZKWO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tZKWO'><tfoot id='tZKWO'></tfoot><dl id='tZKWO'><fieldset id='tZKWO'></fieldset></dl></div>
          • <small id='tZKWO'></small><noframes id='tZKWO'>

          • <tfoot id='tZKWO'></tfoot>

                <legend id='tZKWO'><style id='tZKWO'><dir id='tZKWO'><q id='tZKWO'></q></dir></style></legend>
                • 本文介紹了Cordova Geolocation 插件在 Android 上返回空位置對象的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我在 Geolocation Cordova 插件 (org.apache.cordova.geolocation) 上遇到了很多問題.它在 iOS 上運(yùn)行良好,但在 Android 上根本不行.

                  I've had quite some issues with the Geolocation Cordova plugin (org.apache.cordova.geolocation). It works fine on iOS, but it doesn't at all on Android.

                  據(jù)我了解,該插件曾經(jīng)包含原生 Android 代碼,但在某些時(shí)候被刪除了,因?yàn)樗e(cuò)誤/太慢了,而且原生 Web HTML5 實(shí)現(xiàn)更加穩(wěn)定和快速.

                  As I understand, the plugin used to include native Android code, but this was removed at some point, because it was too buggy/slow and the native web HTML5 implementation was much more stable and fast.

                  如果我使用仍然具有本機(jī)代碼的最新插件版本 (0.3.2),它確實(shí)可以工作(但速度很慢,實(shí)際上并非總是如此).但是當(dāng)它返回時(shí),位置對象總是被填充.

                  If I use the latest plugin version (0.3.2) which still has the native code, it does work (but slow and indeed, not always). But when it does return, the position object is always populated.

                  如果我使用最新的插件版本 (1.0.1),getCurrentPosition() 會立即返回一個(gè)空對象 ({}).它不會拋出錯(cuò)誤.

                  If I use the latest plugin version (1.0.1), the getCurrentPosition() immediately returns with an empty object ({}). It does not throw an error.

                  如果我完全刪除插件,并手動將權(quán)限添加到 Android 項(xiàng)目:

                  If I remove the plugin completely, and add the permissions manually to the Android project:

                  <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" />
                  

                  同樣的事情也會發(fā)生.我只是無法讓它工作,但這沒有意義.Android 控制臺中不會顯示任何錯(cuò)誤.有什么想法嗎?

                  The same thing happens. I just can't get it to work, but it doesn't make sense. No errors are displayed in the Android console. Any thoughts?

                  推薦答案

                  好的,調(diào)試了好久,發(fā)現(xiàn)問題了.顯然,getCurrentPosition() 函數(shù)在 Android 中返回一個(gè)特殊"對象,當(dāng)使用 JSON.stringify() 時(shí),它的計(jì)算結(jié)果為 {}.如果我將原始返回對象輸出到控制臺,結(jié)果證明它根本不是空的.

                  OK, after a long long time of debugging, I found the problem. Apparently, the getCurrentPosition() function returns a 'special' object in Android, which evaluates to {} when using JSON.stringify(). If I outputted the raw return object to the console, it turned out it wasn't empty at all.

                  因此,在荒謬的調(diào)整之后修復(fù)了我的代碼:

                  So, following ridiculous adjustments fixed my code:

                  navigator.geolocation.getCurrentPosition(function (position) {
                      var positionObject = {};
                  
                      if ('coords' in position) {
                          positionObject.coords = {};
                  
                          if ('latitude' in position.coords) {
                              positionObject.coords.latitude = position.coords.latitude;
                          }
                          if ('longitude' in position.coords) {
                              positionObject.coords.longitude = position.coords.longitude;
                          }
                          if ('accuracy' in position.coords) {
                              positionObject.coords.accuracy = position.coords.accuracy;
                          }
                          if ('altitude' in position.coords) {
                              positionObject.coords.altitude = position.coords.altitude;
                          }
                          if ('altitudeAccuracy' in position.coords) {
                              positionObject.coords.altitudeAccuracy = position.coords.altitudeAccuracy;
                          }
                          if ('heading' in position.coords) {
                              positionObject.coords.heading = position.coords.heading;
                          }
                          if ('speed' in position.coords) {
                              positionObject.coords.speed = position.coords.speed;
                          }
                      }
                  
                      if ('timestamp' in position) {
                          positionObject.timestamp = position.timestamp;
                      }
                  
                      // Use the positionObject instead of the position 'object'
                      alert(JSON.stringify(positionObject));            
                  }
                  

                  iOS 無需上述調(diào)整即可正常工作,但由于我的應(yīng)用程序是 Phonegap 應(yīng)用程序,所以我總是應(yīng)用上述內(nèi)容.

                  iOS works fine without above adjustments, but as my app is a Phonegap application, I always apply the above.

                  這篇關(guān)于Cordova Geolocation 插件在 Android 上返回空位置對象的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動期間獲取當(dāng)前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)
                  <tfoot id='FZAzp'></tfoot>
                  1. <i id='FZAzp'><tr id='FZAzp'><dt id='FZAzp'><q id='FZAzp'><span id='FZAzp'><b id='FZAzp'><form id='FZAzp'><ins id='FZAzp'></ins><ul id='FZAzp'></ul><sub id='FZAzp'></sub></form><legend id='FZAzp'></legend><bdo id='FZAzp'><pre id='FZAzp'><center id='FZAzp'></center></pre></bdo></b><th id='FZAzp'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='FZAzp'><tfoot id='FZAzp'></tfoot><dl id='FZAzp'><fieldset id='FZAzp'></fieldset></dl></div>
                  2. <small id='FZAzp'></small><noframes id='FZAzp'>

                        <bdo id='FZAzp'></bdo><ul id='FZAzp'></ul>
                          <tbody id='FZAzp'></tbody>
                          • <legend id='FZAzp'><style id='FZAzp'><dir id='FZAzp'><q id='FZAzp'></q></dir></style></legend>

                          • 主站蜘蛛池模板: 欧美综合在线视频 | 日韩欧美在线免费观看视频 | 福利视频网站 | 亚洲免费三区 | 天天久久 | 日韩av电影院 | 日韩中文字幕网 | 成人国产在线视频 | 国产成人精品视频在线观看 | 干干干操操操 | 日韩午夜 | 在线观看视频一区二区三区 | 欧美日韩在线免费 | 欧美精品v国产精品v日韩精品 | 中文字幕在线观看第一页 | 国产精品91视频 | 久草免费在线视频 | 国产电影一区二区在线观看 | 伊人精品在线 | 国产一区二区在线91 | 日韩中文字幕 | 国产伦精品一区二区三区照片91 | 91看片在线观看 | 日韩欧美三级电影在线观看 | 一区二区三区四区在线视频 | 精品国产一区二区三区久久影院 | 国产免费色| 亚洲在线一区二区三区 | 九九99精品 | 欧美美女被c | 色久电影| 亚洲一区二区电影在线观看 | 成人教育av | 日韩另类视频 | 在线成人av| 夜夜艹 | 91免费福利在线 | 中文字幕第十一页 | 亚洲最大av网站 | 91精品国产一区二区在线观看 | 亚洲电影一区二区三区 |