工作,我已經用下面的代碼Ionic Native Geolocation:離子本地地理位置不是在Android
import { Geolocation } from 'ionic-native';
this.platform.ready().then(() => {
alert('loadMap about to getCurrentPosition');
Geolocation.getCurrentPosition(options).then((position) => {
alert('loadMap getCurrentPosition');
let latLng: google.maps.LatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
bound.extend(latLng);
this.load(bound);
});
});
當我在瀏覽器中運行這個作爲ionic serve
,或者我建立它和iOS Simulator
(Xcode
)運行它,它的工作原理。然而,當我爲Android
構建這個,並嘗試運行它時,第一個警報被激發,但不是第二個。
這意味着只有Android
,Geolocation.getCurrentPosition...
不起作用。
我確實有另一個頁面可以通過this.map = new google.maps.Map(htmlElement, mapOptions);
來渲染地圖,所以看起來問題在於獲取當前位置。當我安裝的應用程序,我卻得到這樣的信息:
Allow AppName to access the device's location? DENY ALLOW
對此我點擊Allow
。
有誰知道我做錯了什麼,或者如果Android安裝和構建過程中有一些缺失的步驟?
謝謝
我一直在使用它一段時間,它的工作。現在突然它不再工作了。沒有代碼更改。我認爲你的代碼很好,但我認爲其他人不穩定。 SOOOOOOO令人沮喪。沒有時間沒有時間 – Harry