android百度定位沒反應,百度定位回調無反應,第一次能回調到數據,第二次無反應...

 2023-10-21 阅读 17 评论 0

摘要:android手機才出現該問題。手機:vivo 系統:android 8.1.0手機:紅米 系統:MIUI 9 7.9.21ios沒有問題問題:map.showUserLocation(true); 在app多次退出重啟的情況下有時候顯示有時候不顯示用戶的位置,顯示時候能正常獲取到定位數據&#

android手機才出現該問題。

手機:vivo 系統:android 8.1.0

手機:紅米 系統:MIUI 9 7.9.21

ios沒有問題

問題:

map.showUserLocation(true); 在app多次退出重啟的情況下有時候顯示有時候不顯示用戶的位置,顯示時候能正常獲取到定位數據,不顯示的時候定位沒有回調,把provider改為‘system’的時能夠在showUserLocation異常的時候獲取到定位數據。

代碼如下:

(該方法在初始化的時候調用一次,然后通過按鈕點擊事件使用計時器循環調用plus.geolocation.getCurrentPosition,初始化的時候能正常獲取到回調,第二次即開啟計時器后回調不了)

function showLocation () {

plus.geolocation.getCurrentPosition(function(position) {

var point = new plus.maps.Point(position.coords.longitude, position.coords.latitude);

/*var marker = new plus.maps.Marker(point);

marker.setIcon(currIcon);

map.addOverlay(marker);*/

//console.log(JSON.stringify(position));

map.showUserLocation(true);

map.centerAndZoom(point, zoomLevel);

}, function(e) {}, {

provider: "baidu",

enableHighAccuracy: true,

coordsType: "bd09ll",

geocode: false

});

}

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/156408.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息