0
我正在使用Google地圖插件和地理位置插件的離子版Google地圖上工作。使用位置更改後更新經緯度的地理定位功能來獲取當前位置。 每一件事情都很好,但我面臨的問題是我想將相機位置移動到當前正在改變位置的位置。當我在movCamera函數中設置固定緯度長度時,它將攝像機移向這些緯度,但是當我將其設置到當前位置時,它會將地圖移動到其他位置,但不是我的位置。將攝像機移動到離子地圖中的當前位置
任何人都可以告訴我最新的問題?
這是代碼。 。 。
export class HomePage {
x: number = 0;
y: number = 0;
constructor(public navCtrl: NavController,private googleMaps: GoogleMaps, public platform:Platform,private geolocation: Geolocation) {
platform.ready().then(() => {
this.loadMap();
});
}
loadMap() {
// create a new map by passing HTMLElement
let element: HTMLElement = document.getElementById('map');
this.geolocation.watchPosition().subscribe((position) => {
this.x = position.coords.longitude;
this.y = position.coords.latitude;
let ionic: LatLng = new LatLng(this.x,this.y);
let map: GoogleMap = this.googleMaps.create(element,{
'backgroundColor': 'white',
'controls': {
'compass': true,
'myLocationButton': true,
'indoorPicker': true,
'zoom': true
},
'gestures': {
'scroll': true,
'tilt': true,
'rotate': true,
'zoom': true
}
});
// listen to MAP_READY event
// You must wait for this event to fire before adding something to the map or modifying it in anyway
map.one(GoogleMapsEvent.MAP_READY).then(() => {
console.log('====>>>>>Map is ready!');
});
let ionic1: LatLng = new LatLng(33.635322,73.073989);
// create CameraPosition
let Camposition: CameraPosition = {
target: ionic,
zoom: 22,
tilt: 30
};
// move the map's camera to position
map.moveCamera(Camposition);
}, (err) => {
console.log(err);
});
}
}