내 Android
기기에 GoogleMap
을 가져올 수 있는데 문제가 내 current
location
을 가리키고 있지 않습니다.내 마커가 현재 위치를 가리키지 않는 이유
$ ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"
$ npm install --save @ionic-native/google-maps
내 구글지도 내 안드로이드 장치에
아래내 코드되는 모습입니다 :
나는이 두 패키지를 설치 한
ionViewDidLoad() {
console.log('ionViewDidLoad GoogleMapTestPage');
this.loadMap();
}
ngAfterViewInit() {
//this.loadMap();
}
loadMap() {
// create a new map by passing HTMLElement
let element: HTMLElement = document.getElementById('map');
let map: GoogleMap = this.googleMaps.create(element);
// 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!');
// Now you can add elements to the map like the marker
}
);
// create LatLng object
let ionic: LatLng = new LatLng(43.0741904,-89.3809802);
// create CameraPosition
let position: any = {
target: ionic,
zoom: 18,
tilt: 30
};
// move the map's camera to position
map.moveCamera(position);
// create new marker
let markerOptions: MarkerOptions = {
position: ionic,
title: 'Ionic'
};
const marker:any = map.addMarker(markerOptions)
.then((marker: Marker) => {
marker.showInfoWindow();
});
}
내 HTML 코드
<ion-content>
<div #map id="map" style="height:100%;"></div>
</ion-content>
내 질문 :
어떻게 위의 코드 내 current location
를 가리 키도록!
내가 3 이온에 새로운 오전 나를 도와주세요, 그냥 구글에
위치에 현재 사용자를 가리 키도록 싶어!
곳이 코드를 추가하려면? 그것은 Google지도에서 현재 위치를 제공 할 것입니다. –
또한 현재 위치에 대한 포인터를 얻고 싶습니다. 현재 위치는 –
이며 위치 정보에서 위도와 경도를 구하고 위 코드로 설정해야합니다.위 라인을 추가하기 위해 코드에서 맵 객체를 만들었습니다. –