使用地理定位與離子(科爾多瓦插件或JavaScript)來獲取用戶的位置,直到最近停止了工作,控制檯登錄以下錯誤:地理位置停在不安全的地點工作,因此對離子
getCurrentPosition() and watchPosition() are deprecated on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See ... for more details.
以下是代碼
navigator.geolocation.getCurrentPosition(function (pos) {
var data = {
Lati: pos.coords.latitude,
Longi: pos.coords.longitude,
/*LoginID: JSON.parse(window.localStorage.getItem('LoginId'))*/
EmpCode: localStorage.getItem('LoginId')
};
console.log(pos.coords.latitude + "," + pos.coords.longitude);
$http.post("https://someapi", data).success(function (rsdata, status) {
console.log(data.Lati + "," + data.Longi);
})
}, function (error) {
alert('Unable to get location: ' + error.message);
});}
這是一個更全球性的問題:https://mobiforge.com/news-comment/no-https-then-bye-bye-geolocation-in-chrome-50 ...網絡將成爲一個安全的地方,這意味着:一切** https ** – Hitmands
@Hitmands我知道它已被棄用..但無法找到一種方式讓它與離子的工作,因爲我可以使一個網站https://但不是一個應用程序 – Yashesh
我認爲有什麼目前... – Hitmands