I have integrated the Google Map in my Ionic 3 app and it was working perfectly, but after some time it stopped working. It gives me error ERROR TypeError: Cannot read property 'constructor' of undefined.
So I've uninstalled the Ionic Native Google Maps plugin and again installed as suggested here.
But when I installed it, it gave me an error TypeError: Object(...) is not a function for ionic native core and it's crashed my app. So I've again downgraded ionic native core plugin to 4.18.0 (the latest one is v. 5.10.0), and the application started work again, but my google map still not working.
My code for google maps is as below.
import {
GoogleMaps,
GoogleMap,
GoogleMapsEvent,
GoogleMapOptions,
CameraPosition,
MarkerOptions,
Marker,
Environment
} from "@ionic-native/google-maps";
export class MapPage {
map: GoogleMap;
constructor() {
}
ionViewDidLoad() {
this.loadMap();
}
loadMap() {
//https://github.com/ionic-team/ionic-native-google-maps/blob/master/documents/markeroptions/README.md'
// This code is necessary for browser
Environment.setEnv({
API_KEY_FOR_BROWSER_RELEASE: "<MY_KEY>",
API_KEY_FOR_BROWSER_DEBUG: "<MY_KEY>"
});
let mapOptions: GoogleMapOptions = {
camera: {
target: {
lat: 25.284538,
lng: 51.511393
},
zoom: 13,
tilt: 30
}
};
this.map = GoogleMaps.create("map_canvas", mapOptions);
this.getMarkers();
}
}