Google지도 플러그인 및 geolocation 플러그인을 사용하여 ionic에서 Google지도 작업 중입니다. 그리고 위치가 변경된 지 오래 후에 위도를 업데이트하는 지리적 위치 정보보기 기능을 사용하여 현재 위치를 확인합니다. 모든 것은 괜찮지 만 내가 직면하고있는 문제는 카메라 위치를 위치를 변경하여 현재 위치로 이동하려는 것입니다. movCamera 함수에서 고정 lat를 길게 설정하면 카메라가이 latlong으로 이동하지만이 값을 현재 위치로 설정하면지도가 다른 위치로 이동하지만 내 위치는 이동하지 않습니다.이온지도에서 현재 위치로 카메라 이동
어느 것이 나에게 문제를 말해 줄 수 있습니까 ??
다음은 코드입니다. . . 다음은 위치를 할당하는
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);
});
}
}