I’m trying to load a basic map onto my template. I just followed this instruction https://ionicframework.com/docs/native/google-maps/ to get my map.
But the error I get is just like the question above.
This is my code
// Load map only after view is initialized ngAfterViewInit() { 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 // // // // 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!'); // Now you can add elements to the map like the marker } ); // 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); } }
I get blank screen and I can’t print console.log in app.component.ts file
Mohan Gopi..
19
I changed my app.module.ts file
import {GoogleMaps,GoogleMap} from '@ionic-native/google-maps'; providers: [ StatusBar, SplashScreen, GoogleMaps, GoogleMap {provide: ErrorHandler, useClass: IonicErrorHandler} ]
About this
import {GoogleMaps} from '@ionic-native/google-maps'; providers: [ StatusBar, SplashScreen, GoogleMaps {provide: ErrorHandler, useClass: IonicErrorHandler} ]
Just removing googleMap from my providers and importing I got it working
1> Mohan Gopi..:
I changed my app.module.ts file
import {GoogleMaps,GoogleMap} from '@ionic-native/google-maps'; providers: [ StatusBar, SplashScreen, GoogleMaps, GoogleMap {provide: ErrorHandler, useClass: IonicErrorHandler} ]
About this
import {GoogleMaps} from '@ionic-native/google-maps'; providers: [ StatusBar, SplashScreen, GoogleMaps {provide: ErrorHandler, useClass: IonicErrorHandler} ]
Just removed googleMap from my providers and imports and I got it working