I create a new fresh Project
ionic start testMap blank --v2
then add google maps following the new documentation for Ionic Native 3
ionic build ios (Everything seems ok)
Then start the project from xcode and run it on a device.
It boots up, but then the maps page is only a white big screen.
Nothing happen.
And on the console the last log is that the device is ready.
allready check on the API Key and its ok, it has no restriccions.
What could be wrong?
My package
{
“name”: “ionic-hello-world”,
“author”: “Ionic Framework”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build”,
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
“@angular/common”: “2.4.8”,
“@angular/compiler”: “2.4.8”,
“@angular/compiler-cli”: “2.4.8”,
“@angular/core”: “2.4.8”,
“@angular/forms”: “2.4.8”,
“@angular/http”: “2.4.8”,
“@angular/platform-browser”: “2.4.8”,
“@angular/platform-browser-dynamic”: “2.4.8”,
“@angular/platform-server”: “2.4.8”,
“@ionic-native/core”: “3.1.0”,
“@ionic-native/geolocation”: “^3.4.2”,
“@ionic-native/google-maps”: “^3.4.2”,
“@ionic-native/splash-screen”: “3.1.0”,
“@ionic-native/status-bar”: “3.1.0”,
“@ionic/storage”: “2.0.0”,
“ionic-angular”: “2.3.0”,
“ionicons”: “3.0.0”,
“rxjs”: “5.0.1”,
“sw-toolbox”: “3.4.0”,
“zone.js”: “0.7.2”
},
“devDependencies”: {
“@ionic/app-scripts”: “1.1.4”,
“typescript”: “2.0.9”
},
“cordovaPlugins”: [
“ionic-plugin-keyboard”,
“cordova-plugin-whitelist”,
“cordova-plugin-console”,
“cordova-plugin-statusbar”,
“cordova-plugin-device”,
“cordova-plugin-splashscreen”
],
“cordovaPlatforms”: [
“ios”,
{
“platform”: “ios”,
“version”: “”,
“locator”: “ios”
}
],
“description”: “testMap: An Ionic project”
}
Home.ts
import {Component} from '@angular/core';
import {NavController, Platform} from 'ionic-angular';
import {
GoogleMaps,
GoogleMap,
GoogleMapsEvent,
LatLng,
CameraPosition,
MarkerOptions,
Marker
} from '@ionic-native/google-maps';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, private platform: Platform, private googleMaps: GoogleMaps) {
platform.ready().then(() => {
this.loadMap();
});
}
loadMap() {
// make sure to create following structure in your view.html file
// and add a height (for example 100%) to it, else the map won't be visible
// <ion-content>
// <div #map id="map" style="height:100%;"></div>
// </ion-content>
// 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!'));
// create LatLng object
let ionic: LatLng = new LatLng(43.0741904, -89.3809802);
// create CameraPosition
let position: CameraPosition = {
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'
};
map.addMarker(markerOptions)
.then((marker: Marker) => {
marker.showInfoWindow();
});
}
}
Home.html
<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<div id="map"></div>
</ion-content>
Home.scss
page-home {
#map {
height: 100%;
}}