Hi everyone,
I’m trying to display a map using the google maps cordova plugin cordova-plugin-googlemaps.
I used the doc available on the ionic native part of the doc of ionic 2 and you can see a section for Google Maps.
The problem is that the doc is almost empty, there is only a single example of using so did a try.
Here is the code of the html page which should display the map:
<ion-header>
<ion-navbar>
<ion-title>
About
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding class="about">
<div id="map"></div>
</ion-content>
This is my code for the typescript file where I use the map:
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {GoogleMap, GoogleMapsEvent} from 'ionic-native';
@Component({
templateUrl: 'build/pages/about/about.html'
})
export class AboutPage {
constructor(private nav: NavController) {
let map = new GoogleMap('map');
map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
console.log("Map is ready!");
map.setVisible(true);
// map.showDialog();
// map.getMyLocation();
// map.showDialog();
});
}
}
The map is not visible on the page but when I uncomment the line map.showDialog() , it shows the map. So I don’t know why the map is not visible on the page
What I also did:
-
When I added the plugin to my project, I took the url of the repo instead of the name of the plugin (it takes the current master version of the plugin and not the one on npm which doesn’t work with the lastest version of cordova-ios) --> I think that it should be mentioned on the doc on your website (http://ionicframework.com/docs/v2/native/google-maps/)
-
I created an API key on the Google Developer Console and configured the plugin with it, so there is no problem with that (I always have the message in the log saying that ‘Map is ready!’)
I tried to find somebody who uses this plugin with Ionic 2 and what I always found was an ionic 2 app using the Google Maps JavaScript API, which is not the best (for me), and I would like to use the Google Maps Cordova Plugin.
I would appreciate if somebody could help me , I used this plugin on an app on ionic 1 without any problem but your new version of Ionic is so beautiful that I want to try it
Have a nice day,
Julien