2016-11-30 2 views
2

나는 이온 2에 익숙하지 않다. 나는 Integrating Native Google Maps into an Ionic 2 Application을 연습하려고 노력하고있다. 그러나 안드로이드 장치에서 앱을 실행하면 다음 그림과 같이 빈 Google지도가 제공된다.ionic 2 blank google map

enter image description here

home.ts 페이지는 다음과 같습니다

<ion-header> 
    <ion-navbar> 
    <ion-title> 
     Ionic Blank 
    </ion-title> 
    </ion-navbar> 
</ion-header> 
<ion-content> 
    <div id="map"></div> 
</ion-content> 

home.scss은 다음과 같습니다

.scroll { 
height: 100%; 
} 
#map { 
width: 100%; 
height: 100%; 
} 
scroll-content._gmaps_cdv_{ 
background-color: transparent !important; 
padding: 0px !important; 
} 
ion-app._gmaps_cdv_ .nav-decor{ 
    background-color: transparent !important; 
} 
home-page { 
} 

home.ts은 다음과 같습니다

import { Component } from '@angular/core'; 
import { NavController, Platform } from 'ionic-angular'; 
import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng } from 'ionic-native'; 
@Component({ 
    selector: 'page-home', 
    templateUrl: 'home.html' 
}) 
export class HomePage { 
    map: GoogleMap; 
    constructor(public navCtrl: NavController, public platform: Platform) { 
    platform.ready().then(() => { 
     this.loadMap(); 
    }); 
    } 
    loadMap(){ 
    let location = new GoogleMapsLatLng(-34.9290,138.6010); 
    this.map = new GoogleMap('map', { 
     'backgroundColor': 'white', 
     'controls': { 
     'compass': true, 
     'myLocationButton': true, 
     'indoorPicker': true, 
     'zoom': true 
     }, 
     'gestures': { 
     'scroll': true, 
     'tilt': true, 
     'rotate': true, 
     'zoom': true 
     }, 
     'camera': { 
     'latLng': location, 
     'tilt': 30, 
     'zoom': 15, 
     'bearing': 50 
     } 
    }); 
    this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => { 
     console.log('Map is ready!'); 
    }); 
    } 
} 

내가 변화하지 않았다 다른 페이지.

내 구글 개발자 콘솔 API 관리자입니다 : 내가 그리워 모르는

enter image description here

.

+0

콘솔에서 api를 활성화하지 않았 음을 의미합니다. 장치에서 위치뿐만 아니라 콘솔도 활성화했는지 확인하십시오. –

+0

api 키를 공개하지 마십시오. 모든지도 컨트롤이 제공되므로 Google지도가 성공적으로 작동합니다. 귀하의 이온 콘텐츠에 클래스를 추가하고 scss에서 클래스 배경과 색상을 투명하게 만듭니다. 그것은 나를 위해 작동합니다. – AishApp

+0

클래스를 추가했지만 나를 위해 작동하지 않습니다. 나는 index.html을 변경해야합니까? –

답변

1

iOS 및 Android 키 제한을 제거하여 문제를 해결했습니다.

+1

이걸 어떻게 할 수 있니? 나는 똑같은 문제가있어 그것을 고칠 수 없다 ... – Luki