Hello there,
I am trying to use the Google Maps Native from ionic 2. The ionic’s documentation provides the follow usage to the home.ts file:
import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng, CameraPosition, GoogleMapsMarkerOptions, GoogleMapsMarker} from 'ionic-native';
export class HomePage {
constructor() {}
ngAfterViewInit() { this.loadMap();}
loadMap() {
let element: HTMLElement = document.getElementById('map');
let map = new GoogleMap(element);
// create LatLng object let ionic: GoogleMapsLatLng = new GoogleMapsLatLng(43.0741904,-89.3809802);
// create CameraPosition let position: CameraPosition = { target: ionic, zoom: 18, tilt: 30 };
// listen to MAP_READY event map.one(GoogleMapsEvent.MAP_READY).then(() => { // move the map's camera to position map.moveCamera(position); // works on iOS and Android});
// create new marker let markerOptions: GoogleMapsMarkerOptions = { position: ionic, title: 'Ionic' };
map.addMarker(markerOptions) .then((marker: GoogleMapsMarker) => { marker.showInfoWindow(); }); }}
So I created the follow home.html file:
<ion-header>
<ion-navbar>
<ion-title> Map </ion-title>
<ion-buttons end> <button ion-button (click)="addMarker()">
<ion-icon name="add"></ion-icon>Add Marker</button> </ion-buttons>
</ion-navbar>
</ion-header>
<ion-content>
<div id="map"></div>
</ion-content>
But when I run the application on the browser, Iḿ getting the error " Uncaught (in promise): [object Object] "
What should I do?