pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

    1. <small id='tZDtx'></small><noframes id='tZDtx'>

      <legend id='tZDtx'><style id='tZDtx'><dir id='tZDtx'><q id='tZDtx'></q></dir></style></legend><tfoot id='tZDtx'></tfoot>
    2. watchPosition() 與 getCurrentPosition() 與 setTimeout

      watchPosition() vs getCurrentPosition() with setTimeout(watchPosition() 與 getCurrentPosition() 與 setTimeout)
            <tbody id='nAbdF'></tbody>

        1. <legend id='nAbdF'><style id='nAbdF'><dir id='nAbdF'><q id='nAbdF'></q></dir></style></legend>
          <i id='nAbdF'><tr id='nAbdF'><dt id='nAbdF'><q id='nAbdF'><span id='nAbdF'><b id='nAbdF'><form id='nAbdF'><ins id='nAbdF'></ins><ul id='nAbdF'></ul><sub id='nAbdF'></sub></form><legend id='nAbdF'></legend><bdo id='nAbdF'><pre id='nAbdF'><center id='nAbdF'></center></pre></bdo></b><th id='nAbdF'></th></span></q></dt></tr></i><div class="op3uike" id='nAbdF'><tfoot id='nAbdF'></tfoot><dl id='nAbdF'><fieldset id='nAbdF'></fieldset></dl></div>
        2. <tfoot id='nAbdF'></tfoot>
            • <bdo id='nAbdF'></bdo><ul id='nAbdF'></ul>

              <small id='nAbdF'></small><noframes id='nAbdF'>

                本文介紹了watchPosition() 與 getCurrentPosition() 與 setTimeout的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我需要確定一個人在 50m 內的位置.我想知道我應該使用 navigator.location.watchPostion() 還是一遍又一遍地調用 getCurrentPostion() .watchPostion() 是正確的 W3C API 來做我想做的事,但實際上,它似乎有點矯枉過正.

                I need to determine a person's location within 50m. I'm wondering if I should use navigator.location.watchPostion() or call getCurrentPostion() over and over again. watchPostion() is the proper W3C API for doing what I want, but practically, it seems to be overkill.

                這是我的代碼:

                var map = null;
                var marker = null;
                var layer = null;
                
                function locFn(pos) {
                
                  var lat = pos.coords.latitude;
                  var lon = pos.coords.longitude;
                
                  $("#hlat").val(lat);
                  $("#hlong").val(lon);
                
                  document.getElementById("lnkMap").href = 
                    "http://maps.google.com/maps?q=My+Loc@" + lat
                    + "," + lon + "&z=18&t=h";
                
                  var point = new GLatLng(lat, lon);
                
                  if (pos.coords.accuracy < 100) {
                    map.setCenter(point, 18);
                
                    if (marker != null) {
                      marker.setLatLng(point);
                    }
                    else {
                      var ico = new GIcon();
                      ico.image = "img/Blue-Dot.png";
                      ico.iconSize = new GSize(22, 22);
                      ico.iconAnchor = new GPoint(11, 11);
                      marker = new GMarker(point, { icon: ico });
                      layer = map.addOverlay(marker, { title: "You are here." });
                    }
                  }
                  else if (pos.coords.accuracy > 2000) {
                    if (marker != null) { marker.setLatLng(point); }
                    map.setCenter(point, 15);
                  }
                  else if (pos.coords.accuracy > 900) {
                    if (marker != null) { marker.setLatLng(point); }
                    map.setCenter(point, 16);
                  }
                  else if (pos.coords.accuracy > 100) {
                    if (marker != null) { marker.setLatLng(point); }
                    map.setCenter(point, 17);
                  }
                }
                
                function locFail() {
                  //alert("Failed to retrieve location.");
                }
                
                var watchID = null;
                
                function processPoints() {
                  map = new GMap2(document.getElementById("map_canvas"), 
                                  { mapTypes: [G_HYBRID_MAP] });
                  try {
                    watchID = navigator.geolocation.watchPosition(locFn, locFail,
                          { enableHighAccuracy: true });
                  }
                  catch(err) { /* desktop?*/ }
                }
                $(function(){processPoints();});
                

                我注意到 watchPostion() 似乎最終會導致更高的準確性(一段時間后),但我想知道位置變化是否如此之快以至于導致很多事情下載到我的地圖畫布,不斷的 http 請求很快就會過時,被新的請求所取代.當我使用 watchPosition() 時,頁面加載需要一段時間.

                I've noticed watchPostion() seems to ultimately result in more accuracy (after a while), but I'm wondering if the position changes so fast that it results in a lot of thing being downloaded to my map canvas, with constant http requests that are soon out-of-date, replaced by the new ones coming in. When I use watchPosition(), it does take a while before the page loads.

                推薦答案

                經過一些認真的測試,我已經驗證了 watchPosition() 會比 getCurrentPostion() 一遍又一遍地更快地為您提供準確的位置.使用 watchPostion() 時,如果您在每次設備更新您的位置時一遍又一遍地重新繪制地圖,則地圖的行為會很差.為了解決這個問題,我在 tilesloaded 事件中添加了一個偵聽器,它允許我僅在沒有線程嘗試在地圖上繪制時才重繪地圖.一旦用戶對確定的位置感到滿意,我將清除手表.就電池消耗和準確性而言,這將使我兩全其美.

                After some serious testing, I have verified watchPosition() will give you an accurate location much more quickly than getCurrentPostion() over and over again. When using watchPostion(), the map behaves poorly if you redraw it over and over again every time the device updates your location. To get around this, I have added a listener to the tilesloaded event, which allows me to only redraw the map if there is not already a thread trying to draw on the map. Once the user is happy with the determined location, I will clear the watch. This will get me the best of both worlds, as far as battery consumption and accuracy are concerned.

                這篇關于watchPosition() 與 getCurrentPosition() 與 setTimeout的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經度計算 X 和 Y)
                CLLocation returning negative speed(CLLocation 返回負速度)
                How to Search in Google Map Api V2 Android?(如何在 Google Map Api V2 Android 中搜索?)
                Calculate bearing between two locations (lat, long)(計算兩個位置之間的方位角(緯度、經度))
                Android Google Map how to check if the gps location is inside the circle(Android Google Map如何檢查gps位置是否在圓圈內)
                Using Google Maps location without Activity(在沒有活動的情況下使用 Google 地圖位置)
                    • <bdo id='kdUkH'></bdo><ul id='kdUkH'></ul>

                      <i id='kdUkH'><tr id='kdUkH'><dt id='kdUkH'><q id='kdUkH'><span id='kdUkH'><b id='kdUkH'><form id='kdUkH'><ins id='kdUkH'></ins><ul id='kdUkH'></ul><sub id='kdUkH'></sub></form><legend id='kdUkH'></legend><bdo id='kdUkH'><pre id='kdUkH'><center id='kdUkH'></center></pre></bdo></b><th id='kdUkH'></th></span></q></dt></tr></i><div class="p3ocuzi" id='kdUkH'><tfoot id='kdUkH'></tfoot><dl id='kdUkH'><fieldset id='kdUkH'></fieldset></dl></div>
                      <tfoot id='kdUkH'></tfoot>
                      <legend id='kdUkH'><style id='kdUkH'><dir id='kdUkH'><q id='kdUkH'></q></dir></style></legend>
                        <tbody id='kdUkH'></tbody>
                    • <small id='kdUkH'></small><noframes id='kdUkH'>

                        1. 主站蜘蛛池模板: 对辊式破碎机-对辊制砂机-双辊-双齿辊破碎机-巩义市裕顺机械制造有限公司 | 伟秀电气有限公司-10kv高低压开关柜-高低压配电柜-中置柜-充气柜-欧式箱变-高压真空断路器厂家 | 斗式提升机_链式斗提机_带式斗提机厂家无锡市鸿诚输送机械有限公司 | 温州食堂承包 - 温州市尚膳餐饮管理有限公司 | 鼓风干燥箱_真空烘箱_高温干燥箱_恒温培养箱-上海笃特科学仪器 | 专业的压球机生产线及解决方案厂家-河南腾达机械厂 | 粘弹体防腐胶带,聚丙烯防腐胶带-全民塑胶 | 无缝钢管-聊城无缝钢管-小口径无缝钢管-大口径无缝钢管 - 聊城宽达钢管有限公司 | atcc网站,sigma试剂价格,肿瘤细胞现货,人结肠癌细胞株购买-南京科佰生物 | 闭端端子|弹簧螺式接线头|防水接线头|插线式接线头|端子台|电源线扣+护线套|印刷电路板型端子台|金笔电子代理商-上海拓胜电气有限公司 | 苗木价格-苗木批发-沭阳苗木基地-沭阳花木-长之鸿园林苗木场 | 酒精检测棒,数显温湿度计,酒安酒精测试仪,酒精检测仪,呼气式酒精检测仪-郑州欧诺仪器有限公司 | 重庆波纹管|重庆钢带管|重庆塑钢管|重庆联进管道有限公司 | 代办建筑资质升级-建筑资质延期就找上海国信启航 | 仿真植物|仿真树|仿真花|假树|植物墙 - 广州天昆仿真植物有限公司 | 除尘器布袋骨架,除尘器滤袋,除尘器骨架,电磁脉冲阀膜片,卸灰阀,螺旋输送机-泊头市天润环保机械设备有限公司 | 汽车润滑油厂家-机油/润滑油代理-高性能机油-领驰慧润滑科技(河北)有限公司 | 筒瓦厂家-仿古瓦-寺庙-古建琉璃瓦-宜兴市古典园林建筑陶瓷厂有限公司 | RV减速机-蜗轮蜗杆减速机-洗车机减速机-减速机厂家-艾思捷 | 上海租车公司_上海包车_奔驰租赁_上海商务租车_上海谐焕租车 | 亿诺千企网-企业核心产品贸易| 温泉机设备|温泉小镇规划设计|碳酸泉设备 - 大连连邦温泉科技 | 恒温油槽-恒温水槽-低温恒温槽厂家-宁波科麦仪器有限公司 | 千斤顶,液压千斤顶-力良企业,专业的液压千斤顶制造商,shliliang.com | RTO换向阀_VOC高温阀门_加热炉切断阀_双偏心软密封蝶阀_煤气蝶阀_提升阀-湖北霍科德阀门有限公司 | 海水晶,海水素,海水晶价格-潍坊滨海经济开发区强隆海水晶厂 | 东莞办公家具厂家直销-美鑫【免费3D效果图】全国办公桌/会议桌定制 | 协议书_协议合同格式模板范本大全| 桥架-槽式电缆桥架-镀锌桥架-托盘式桥架 - 上海亮族电缆桥架制造有限公司 | 熔体泵|换网器|熔体齿轮泵|熔体计量泵厂家-郑州巴特熔体泵有限公司 | 南京兰江泵业有限公司-水解酸化池潜水搅拌机-絮凝反应池搅拌机-好氧区潜水推进器 | 石膏基自流平砂浆厂家-高强石膏基保温隔声自流平-轻质抹灰石膏粉砂浆批发-永康市汇利建设有限公司 | 雷达液位计_超声波风速风向仪_雨量传感器_辐射传感器-山东风途物联网 | 磷酸肌酸二钠盐,肌酐磷酰氯-沾化欣瑞康生物科技 | SMN-1/SMN-A ABB抽屉开关柜触头夹紧力检测仪-SMN-B/SMN-C-上海徐吉 | 废旧物资回收公司_广州废旧设备回收_报废设备物资回收-益美工厂设备回收公司 | 北京网站建设公司_北京网站制作公司_北京网站设计公司-北京爱品特网站建站公司 | 智能门锁电机_智能门锁离合器_智能门锁电机厂家-温州劲力智能科技有限公司 | 托利多电子平台秤-高精度接线盒-托利多高精度电子秤|百科 | 膜结构车棚|上海膜结构车棚|上海车棚厂家|上海膜结构公司 | 包装设计公司,产品包装设计|包装制作,包装盒定制厂家-汇包装【官方网站】 |