Ionic-native: Google Maps: "Can't find variable 'plugin'" error

Created on 21 Jun 2016  路  5Comments  路  Source: ionic-team/ionic-native

I am trying to use the Google Maps plugin, like so:

import {Component} from "@angular/core";
import {GoogleMap, GoogleMapsEvent} from "ionic-native";

@Component({
  templateUrl: 'build/pages/map/map.html'
})
export class MapPage {
  constructor() {}

  ngOnInit() {
    let map = new GoogleMap('.map-canvas');
    map.on(GoogleMapsEvent.MAP_READY).subscribe(() => console.log("Map is ready!"));
  }
}

And I get this error:
"EXCEPTION: Error: Uncaught (in promise): ReferenceError: Can't find variable: plugin"

Using Ionic 2.0 beta 9, and Ionic Native version 1.3.0.

Any ideas?

question

Most helpful comment

You need to wrap it with platform.onReady(), and you might need to move your code to be inside the constructor as well.

All 5 comments

You need to wrap it with platform.onReady(), and you might need to move your code to be inside the constructor as well.

Alright so I have installed the plugins and the problem was gone. Now for some reason there is a blank screen on my iPhone when I try to view the map. Any idea was causes this?

Not sure, I haven't tested this on iOS yet.

Can you try to see if there are any logs from the Google Maps plugin?

Also check that you provided the variable --variable API_KEY_FOR_IOS while installing the plugin, see package.json

No, nothing. No errors in XCode at all, or in Safari developer debug. The application is clear from any errors.

I also get the "Map ready!" console log.

You have to use an ID, not a class.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

goleary picture goleary  路  3Comments

kyleap picture kyleap  路  4Comments

icchio picture icchio  路  3Comments

lycwed picture lycwed  路  4Comments

ajcrites picture ajcrites  路  3Comments