How to use Ionic Google Maps without Cordova?

I am building a PWA with Ionic, so I don’t need Cordova. Following the instructions to use the Ionic Google Maps for Ionic v4 it says to add a Cordova plugin, with the API keys. Source https://github.com/mapsplugin/ionic-googlemaps-quickdemo-v4

Questions:

  • Is it possible to use @ionic-native/google-maps@5.0.xxx-beta without Cordova?
  • Where should I set the API Key?

Thanks

1 Like

I used this website for my integration: https://www.joshmorony.com/ionic-2-how-to-use-google-maps-geolocation-video-tutorial/

1 Like

This demo is built with cordova browser platform. So cordova is required.

Here is steps that how to build this project for PWA.

$> git clone https://github.com/mapsplugin/ionic-googlemaps-quickdemo-v4

$> vim package.json  // then replace `(YOUR_API_KEY)` with your key
https://github.com/mapsplugin/ionic-googlemaps-quickdemo-v4/blob/master/package.json#L83-L84

$> vim config.xml  //  then replace `(YOUR_API_KEY)` with your key

$> npm i

$> ionic cordova prepare

$> npm run buildwww
https://github.com/mapsplugin/ionic-googlemaps-quickdemo-v4/blob/master/package.json#L13
1 Like

Oh, ok then. I thought that if I was build a PWA I shouldn’t use Cordova at all. But if there’s the option to build Cordova for browser, it seems about right. Thanks for your attention!

You have a few options, for example:

1 Like

After buidlwww, can I deploy all files in doc directory to Firebase for hosting?

Very Thanks. It works!!! But it’s not easy to develop for browser platform because there is not any support for live-reload. I found your suggestion at https://github.com/mapsplugin/cordova-plugin-googlemaps#browser-platform . But the plugin, cordova-plugin-browsersync doesn’t look like working any more.

In Ionic 4 you can opt for JavaScript Google Maps check this tutorial on same

1 Like