cordova-plugin-googlemaps: console.warn: Native: tried accessing the GoogleMaps plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
That is the error appearing in the console, i run the project in my mobile phone so i dont understand why cordova is unavailable.
This is my code:
import { Component } from '@angular/core';
import { NavController, NavParams, Platform } from 'ionic-angular';
import {
GoogleMaps,
GoogleMap,
GoogleMapsEvent,
LatLng,
CameraPosition,
MarkerOptions,
Marker
} from '@ionic-native/google-maps';
@Component({
selector: 'page-map',
templateUrl: 'map.html',
})
export class MapPage {
latitud: any;
longitud: any;
map: GoogleMap;
constructor(public navCtrl: NavController, public navParams: NavParams, private googleMaps: GoogleMaps, public platform: Platform) {
this.latitud = "-38.007681";
this.longitud = "-57.543674";
}
ionViewDidLoad() {
this.loadMap();
}
loadMap() {
let mapOptions = {
camera: {
target: {
lat: Number(this.latitud),
lng: Number(this.longitud)
},
zoom: 18,
tilt: 30
}
};
this.map = GoogleMaps.create('map', mapOptions);
// listen to MAP_READY event
// You must wait for this event to fire before adding something to the map or modifying it in anyway
this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
console.log('Map is ready!');
});
}
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 32 (17 by maintainers)
Yeah, very weird. I haven’t experienced this situation. But the problem is definitely ionic problem.
By the way, this presentation might help you use this plugin through
@ionic-native/google-maps. https://docs.google.com/presentation/d/1zlkmoSY4AzDJc_P4IqWLnzct41IqHyzGkLeyhlAxMDE/edit#slide=id.p