google map
이 (가) android
기기에 나타나지 않는 이유는 무엇입니까?왜 lat lang이있는 ionic 3 Google지도가 안드로이드에로드되지 않고
브라우저에서 나는 console.log(); lat, lang
입니다. 기기가 위치 액세스 권한을 요청하지만 render map
이 아닙니다. 코드 아래
미리 정의 된 lat, lang
ionViewDidLoad() {
console.log('ionViewDidLoad GoogleMapTestPage');
this.loadMapHandler();
}
loadMapHandler() {
//console.log(lat,lang);
// create a new map by passing HTMLElement
let element: HTMLElement = document.getElementById('map');
let map: GoogleMap = this.googleMaps.create(element);
// create CameraPosition
let position: any = {
target: LatLng,
zoom: 18,
tilt: 30
};
map.one(GoogleMapsEvent.MAP_READY).then(() => {
console.log('Map is ready!');
// Now you can add elements to the map like the marker
map.moveCamera(position);
// create new marker
let markerOptions:any = {
position: LatLng,
title: 'Ionic'
};
const marker:any = map.addMarker(markerOptions)
.then((marker: Marker) => {
marker.showInfoWindow();
});
});
}
내가 사용자의 현재 위치를 얻을과 다른, 위도를 사용하여 lang을 통과 할 때 위의 코드는 안드로이드
에 잘 작동을 위해 잘 작동
기능을 수행하면 작동하지 않습니다.
은 다음과 안드로이드에서 작동하지
코드가 작동하지 않는 내 코드입니다 : 권한을 요청하지만, 사전에
import { Geolocation ,GeolocationOptions } from '@ionic-native/geolocation';
constructor(...,public googleMaps: GoogleMaps,private geolocation : Geolocation) {
}
ionViewDidLoad() {
this.loadMap();
}
loadMap(){
this.geolocation.getCurrentPosition().then((position) => {
this.loadMapHandler(position.coords.latitude,position.coords.longitude);
}, (err) => {
console.log(err);
});
}
loadMapHandler(lat,lang) {
console.log(lat,lang); // console.log('is giving map co-ordinates');
// create a new map by passing HTMLElement
let element: HTMLElement = document.getElementById('map');
let map: GoogleMap = this.googleMaps.create(element);
let ionic: LatLng = new LatLng(lat,lang);
// create CameraPosition
let position: any = {
target: LatLng,
zoom: 18,
tilt: 30
};
map.one(GoogleMapsEvent.MAP_READY).then(() => {
console.log('Map is ready!');
// Now you can add elements to the map like the marker
map.moveCamera(position);
// create new marker
let markerOptions:any = {
position: LatLng,
title: 'Ionic'
};
const marker:any = map.addMarker(markerOptions)
.then((marker: Marker) => {
marker.showInfoWindow();
});
});
}
감사를 작동하지 않습니다! 당신이 Google지도 플러그인을 사용하는 경우
을 –
@SurajRao, 죄송합니다 내가 편집하는 내 실제 코드를 엉망으로 만들었습니다. 지금 편집 할 것입니다. –
@SurajRao, 이온 성 네이티브 기능을 온라인으로 실행하는 방법이 있습니까? –