How it works...

The core of this app is mainly in the JavaScript code-home.ts. In order to use the plugin object, you should declare it on top, as shown here:

import {  GoogleMaps,GoogleMap,GoogleMapsEvent,GoogleMapOptions,  CameraPosition,LatLng,MarkerOptions,Marker} from '@ionic-native/google-maps';

While it might seem that there are a lot of moving parts, the basic flow is very simple, as listed here:

  1. Whenever Ionic and Cordova are ready, trigger platform.ready().then to initialize the map by calling showMap() in the constructor of the HomePage.
  2. When a user clicks on the button, the app will call getMyLocation to get the location data.
  3. The data will be used to create the marker and move the map's camera to center on that location.

It's ...

Get Ionic Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.