Cordova Google Maps Plugin and cordova-android 11

I’ve been using the Google Maps Plugin for many years now in Cordova projects. It provides access to native Google maps, which imho gives a better user experience than using the JavaScript api.

Sadly the plugin doesn’t get updated anymore, even though I bought the developer a virtual beer a while ago. After having read this discussion I first tried using the fork at https://github.com/we-are-joinup/cordova-plugin-googlemaps/ :

  1. Create the project and cd into the project directory
  2. run cordova plugin add https://github.com/we-are-joinup/cordova-plugin-googlemaps/
  3. run cordova platform add android@11.0.0
  4. in platforms/android/cordova-plugin-googlemaps/***-tbxml-android.gradle : in the dependencies {} replace compile by implementation

Building and running the app went fine, the map opened nicely, custom markers showed up after setting the right path. But getMyLocation would always fail, making this road a dead end. Back to the original plugin.

Here’s how I got 2.7.1 going, with an additional plugin and some Java code patches:

  1. Create the project and cd into the project directory (or, when already present, remove the maps plugin and the Android platform)
  2. run cordova plugin add cordova-plugin-androidx-adapter
  3. run cordova plugin add cordova-plugin-google-maps
  4. Apply all patches mentioned here
  5. run cordova platform add android@11.0.0

Building and running the app went fine, and this time getMyLocation would actually work.

Leave a Reply

Your email address will not be published. Required fields are marked *

This form collects your name, email address and content so that we can keep track of the comments placed on the website. Check our privacy policy for more info on where, how and why we store your data.