Use Google Maps SDK
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.6.3-20190614-1928" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.6.3-20190730-1847" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="Promise" src="www/Promise.js" />
<js-module name="BaseClass" src="www/BaseClass.js">
<resource-file src="src/android/frameworks/tbxml-android.aar" target="app/src/libs/tbxml-android.aar"/>
- <framework src="src/android/frameworks/apikey.gradle" custom="true" type="gradleReference"/>
+ <framework src="src/android/frameworks/pgm-custom.gradle" custom="true" type="gradleReference"/>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
- <meta-data android:name="com.google.android.geo.API_KEY" android:value="${GOOGLE_MAPS_ANDROID_API_KEY}"/>
+ <meta-data android:name="com.google.android.geo.API_KEY" android:value="GOOGLE_MAPS_ANDROID_API_KEY"/>
<!-- Google Play Services SDK -->
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
<!-- for Android 9 or above -->
<resource-file src="src/android/res/drawable/dummy_my_location_button.png" target="res/drawable/dummy_my_location_button.png"/>
<resource-file src="src/android/res/drawable/dummy_mylocation_button_shadow.xml" target="res/drawable/dummy_mylocation_button_shadow.xml"/>
- <!-- Minimum required version of Google Play Services SDK for this plugin is 12.0.1. You need to specify this version number for all other plugins that use google play services sdk. https://developers.google.com/android/guides/releases -->
- <preference name="PLAY_SERVICES_VERSION" default="15.0.1"/>
- <framework src="com.google.android.gms:play-services-maps:$PLAY_SERVICES_VERSION"/>
- <framework src="com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION"/>
-
- <!-- Minimum required version of Android Support library v4 for this plugin. https://developers.google.com/android/guides/releases -->
- <preference name="ANDROID_SUPPORT_V4_VERSION" default="27.+"/>
- <framework src="com.android.support:support-core-utils:$ANDROID_SUPPORT_V4_VERSION"/>
-
<!-- Base messages -->
<resource-file src="src/android/res/values/pgm_strings.xml" target="res/values/pgm_strings.xml"/>
<!-- localized messages for Spanish -->

RENAME
src/android/frameworks/apikey.gradle
src/android/frameworks/pgm-custom.gradle
@@ -38,22 +38,62 @@ android {
}
println("preference = " + widget.preference.size())
Properties props = new Properties()
- def found = 0
+ def isKeyFound = 0
+ def useBetaSdk = 0
+ props.setProperty("GOOGLE_MAPS_PLAY_SERVICES_VERSION", "16.0.0");
+ props.setProperty("ANDROID_SUPPORT_V4_VERSION", "27.1.1");
+ props.setProperty("GOOGLE_MAPS_ANDROID_SDK", "");
+
widget.preference.each { pref ->
def name = pref.attributes().name
def value = pref.attributes().value
- println("name = " + name + ", value = " + value);
+ println("name = " + name);
if (name == "GOOGLE_MAPS_ANDROID_API_KEY") {
- found = 1
- props.setProperty(name, value);
+ isKeyFound = 1
+ props.setProperty(name, value)
+ }
+ if (name == "GOOGLE_MAPS_PLAY_SERVICES_VERSION" ||
+ name == "ANDROID_SUPPORT_V4_VERSION") {
+ props.setProperty(name, value)
+ }
+ if (name == "GOOGLE_MAPS_ANDROID_SDK") {
+ useBetaSdk = 1
+ props.setProperty("GOOGLE_MAPS_ANDROID_SDK", value)
}
}
- if (found == 0) {
+ if (isKeyFound == 0) {
throw new GradleException("Please add '<preference name=\"GOOGLE_MAPS_ANDROID_API_KEY\" />' to the config.xml file.")
}
+ if (useBetaSdk == 1) {
+ def libsDirPath = System.getProperty("user.dir")
+ def libsDir = new File("${libsDirPath}/platforms/android/app/libs/")
+ if (!libsDir.exists()) {
+ libsDir.mkdirs()
+ }
+ // println("---->libsDir = ${libsDir.absolutePath}/" + props.getProperty("GOOGLE_MAPS_ANDROID_SDK"))
+
+ def mapsSDK = props.getProperty("GOOGLE_MAPS_ANDROID_SDK")
+ def f = new File("${libsDir.absolutePath}/${mapsSDK}.aar")
+ // println("---->lib = " + f.absolutePath);
+ if (!f.exists()) {
+ new URL("https://dl.google.com/dl/geosdk/${mapsSDK}.aar").withInputStream{ i -> f.withOutputStream{ it << i }}
+ }
+ dependencies {
+ implementation name: mapsSDK, ext:'aar'
+ }
+ }
+
+ def PLAY_SERVICES_VERSION = props.get("GOOGLE_MAPS_PLAY_SERVICES_VERSION")
+ def ANDROID_SUPPORT_V4_VERSION = props.get("ANDROID_SUPPORT_V4_VERSION")
+ dependencies {
+ implementation "com.google.android.gms:play-services-maps:${PLAY_SERVICES_VERSION}"
+ implementation "com.google.android.gms:play-services-location:${PLAY_SERVICES_VERSION}"
+ implementation "com.android.support:support-core-utils:${ANDROID_SUPPORT_V4_VERSION}"
+ }
+
buildTypes {
debug {

MODIFY
src/android/frameworks/tbxml-android.gradle
src/android/frameworks/tbxml-android.gradle
@@ -8,7 +8,7 @@ repositories {
}
dependencies {
- compile(name:'tbxml-android', ext:'aar')
+ implementation(name:'tbxml-android', ext:'aar')
}
android {

Use Google Maps SDK