Create install_libs.js and uninstall_libs.js for cordova-android@7
MODIFY
README.md
README.md
-# Cordova GoogleMaps plugin for iOS and Android (version 2.2.2)
+# Cordova GoogleMaps plugin for iOS and Android (version 2.2.3)
This plugin is a thin wrapper for [Google Maps Android API](https://developers.google.com/maps/documentation/android/) and [Google Maps SDK for iOS](https://developers.google.com/maps/documentation/ios/).
@@ -20,6 +20,27 @@ $> cordova plugin add cordova-plugin-googlemaps \
LOCATION_ALWAYS_USAGE_DESCRIPTION="My custom always usage message" (for iOS)
```
+## PhoneGap Build settings
+
+```xml
+<widget ...>
+ <plugin name="cordova-plugin-googlemaps" spec="^2.2.3">
+ <variable name="API_KEY_FOR_ANDROID" value="(api key)" />
+ <variable name="API_KEY_FOR_IOS" value="(api key)" />
+ <variable name="PLAY_SERVICES_VERSION" value="11.8.0" />
+ <variable name="LOCATION_WHEN_IN_USE_DESCRIPTION" value="Show your location on the map" />
+ <variable name="LOCATION_ALWAYS_USAGE_DESCRIPTION" value="Trace your location on the map" />
+ </plugin>
+
+ <!--
+ You need to specify cli-7.1.0 or greater version.
+ https://build.phonegap.com/current-support
+ -->
+ <preference name="phonegap-version" value="cli-7.1.0" />
+</widget>
+```
+
+
## Release Notes
@@ -35,6 +56,8 @@ $> cordova plugin add cordova-plugin-googlemaps \
- **v2.2.2**
- Bug fix: the icon property of Marker class does not affect
+- **v2.2.3**
+ - Bug fix: the icon property of Marker class does not affect if the html is hosted on `file://android_assets/`.
## Quick demo

MODIFY
package.json
package.json
{
"name": "cordova-plugin-googlemaps",
- "version": "2.2.2",
+ "version": "2.2.3",
"description": "Google Maps native SDK for Android and iOS",
"cordova": {
"id": "cordova-plugin-googlemaps",

MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.2.3-beta-20180202-1842" 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.2.3" 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="BaseClass" src="www/BaseClass.js">
<runs />
@@ -132,7 +132,7 @@ The native map view is faster, use less network usage, display 3D views, and eve
<preference name="android-minSdkVersion" value="19" />
</config-file>
- <config-file target="res/xml/config.xml" parent="/*">
+ <config-file target="src/res/xml/config.xml" parent="/*">
<feature name="CordovaGoogleMaps">
<param name="android-package" value="plugin.google.maps.CordovaGoogleMaps" />
<param name="onload" value="true" />
@@ -184,12 +184,12 @@ The native map view is faster, use less network usage, display 3D views, and eve
<source-file src="src/android/plugin/google/maps/MyPlugin.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/MyPluginLayout.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/MyPluginInterface.java" target-dir="src/plugin/google/maps" />
+ <source-file src="src/android/plugin/google/maps/PluginMap.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginCircle.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginGeocoder.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginLocationService.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginGroundOverlay.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginKmlOverlay.java" target-dir="src/plugin/google/maps" />
- <source-file src="src/android/plugin/google/maps/PluginMap.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginMarker.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginPolygon.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginPolyline.java" target-dir="src/plugin/google/maps" />
@@ -201,15 +201,11 @@ The native map view is faster, use less network usage, display 3D views, and eve
<source-file src="src/android/plugin/google/maps/PluginMarkerCluster.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/tbxml-android/src/za/co/twyst/tbxml/TBXML.java" target-dir="src/za/co/twyst/tbxml" />
- <source-file src="src/android/tbxml-android/libs/arm64-v8a/libtbxml.so" target-dir="libs/arm64-v8a/" />
- <source-file src="src/android/tbxml-android/libs/armeabi/libtbxml.so" target-dir="libs/armeabi/" />
- <source-file src="src/android/tbxml-android/libs/armeabi-v7a/libtbxml.so" target-dir="libs/armeabi-v7a/" />
- <source-file src="src/android/tbxml-android/libs/mips/libtbxml.so" target-dir="libs/mips/" />
- <source-file src="src/android/tbxml-android/libs/mips64/libtbxml.so" target-dir="libs/mips64/" />
- <source-file src="src/android/tbxml-android/libs/x86/libtbxml.so" target-dir="libs/x86/" />
- <source-file src="src/android/tbxml-android/libs/x86_64/libtbxml.so" target-dir="libs/x86_64/" />
+ <hook type="after_plugin_add" src="src/android/install_libs.js" />
+ <hook type="after_platform_add" src="src/android/install_libs.js" />
+ <hook type="before_plugin_uninstall" src="src/android/uninstall_libs.js" />
- <config-file target="AndroidManifest.xml" parent="/manifest/application">
+ <config-file target="src/AndroidManifest.xml" parent="/manifest/application">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="$API_KEY_FOR_ANDROID" />
@@ -218,7 +214,7 @@ The native map view is faster, use less network usage, display 3D views, and eve
android:value="@integer/google_play_services_version" />
</config-file>
- <config-file target="AndroidManifest.xml" parent="/manifest">
+ <config-file target="src/AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- The following two permissions are not required to use

ADD
src/android/install_libs.js
+module.exports = function(ctx) {
+ if (ctx.opts.cordova.platforms.indexOf('android') < 0) {
+ return;
+ }
+
+ var fs = ctx.requireCordovaModule('fs'),
+ path = ctx.requireCordovaModule('path'),
+ Q = ctx.requireCordovaModule('q');
+
+ var projectRoot = ctx.opts.projectRoot;
+ var configXml = fs.readFileSync(path.join(projectRoot, "config.xml")) + "";
+ var matches = configXml.match(/engine name=\"android\" spec=\"(.+?)\"/gi);
+ if (!matches) {
+ return;
+ }
+ matches[0] = matches[0].replace(/engine name=\"android\" spec=\"~?([\d\.]+)\"/g, "$1");
+ var androidLibVersion = parseInt(matches[0].replace(/\./g, ""), 10);
+ var androidPlatformDir = path.join(projectRoot, "platforms", "android");
+ var androidProjDir = (androidLibVersion >= 700) ? path.join("app", "src", "main") : "";
+ androidProjDir = path.join(androidPlatformDir, androidProjDir);
+ var dstLibsDir = path.join(androidProjDir, "libs");
+ var tbxmlSource = path.join(__dirname, "tbxml-android", "libs");
+
+ var copyFile = function(filename, srcDir, dstDir) {
+ return Q.promise(function(resolve, reject, notify) {
+ fs.stat(dstDir, function(error, stat) {
+ if (error || !stat) {
+ fs.mkdirSync(dstDir);
+ }
+ var srcFile = path.join(srcDir, filename);
+ var dstFile = path.join(dstDir, filename);
+
+ // for debug
+ // console.log(" [copy] " + srcFile + " -> " + dstFile);
+ fs.writeFileSync(dstFile, fs.readFileSync(srcFile));
+ resolve();
+ });
+ });
+ };
+
+ return Q.Promise(function(resolve, reject, notify) {
+ fs.stat(dstLibsDir, function(error, stat) {
+ if (error || !stat) {
+ fs.mkdirSync(dstLibsDir);
+ }
+
+ var files = [];
+ files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "arm64-v8a"), path.join(dstLibsDir, "arm64-v8a")));
+ files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "armeabi"), path.join(dstLibsDir, "armeabi")));
+ files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "armeabi-v7a"), path.join(dstLibsDir, "armeabi-v7a")));
+ files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "mips"), path.join(dstLibsDir, "mips")));
+ files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "mips64"), path.join(dstLibsDir, "mips64")));
+ files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "x86"), path.join(dstLibsDir, "x86")));
+ files.push(copyFile("libtbxml.so", path.join(tbxmlSource, "x86_64"), path.join(dstLibsDir, "x86_64")));
+
+ resolve(files);
+ });
+ })
+ .then(function(files) {
+ return Q.all(files);
+ });
+
+};

ADD
src/android/uninstall_libs.js
+module.exports = function(ctx) {
+ if (ctx.opts.cordova.platforms.indexOf('android') < 0) {
+ return;
+ }
+
+ var fs = ctx.requireCordovaModule('fs'),
+ path = ctx.requireCordovaModule('path'),
+ Q = ctx.requireCordovaModule('q');
+
+ var projectRoot = ctx.opts.projectRoot;
+ var configXml = fs.readFileSync(path.join(projectRoot, "config.xml")) + "";
+ var matches = configXml.match(/engine name=\"android\" spec=\"(.+?)\"/gi);
+ if (!matches) {
+ return;
+ }
+ matches[0] = matches[0].replace(/engine name=\"android\" spec=\"~?([\d\.]+)\"/g, "$1");
+ var androidLibVersion = parseInt(matches[0].replace(/\./g, ""), 10);
+ var androidPlatformDir = path.join(projectRoot, "platforms", "android");
+ var androidProjDir = (androidLibVersion >= 700) ? path.join("app", "src", "main") : "";
+ androidProjDir = path.join(androidPlatformDir, androidProjDir);
+ var dstLibsDir = path.join(androidProjDir, "libs");
+ var tbxmlSource = path.join(__dirname, "tbxml-android", "libs");
+
+ var removeFile = function(filepath) {
+ return Q.promise(function(resolve, reject, notify) {
+ fs.stat(filepath, function(error, stat) {
+ if (error || !stat) {
+ resolve();
+ return;
+ }
+ // for debug
+ // console.log("[remove] " + filepath);
+ fs.unlink(filepath, function() {
+ resolve();
+ });
+ });
+ });
+ };
+
+ return Q.Promise(function(resolve, reject, notify) {
+ fs.stat(dstLibsDir, function(error, stat) {
+ if (error || !stat) {
+ resolve();
+ return;
+ }
+
+ var files = [];
+ files.push(removeFile(path.join(dstLibsDir, "arm64-v8a", "libtbxml.so")));
+ files.push(removeFile(path.join(dstLibsDir, "armeabi", "libtbxml.so")));
+ files.push(removeFile(path.join(dstLibsDir, "armeabi-v7a", "libtbxml.so")));
+ files.push(removeFile(path.join(dstLibsDir, "mips", "libtbxml.so")));
+ files.push(removeFile(path.join(dstLibsDir, "mips64", "libtbxml.so")));
+ files.push(removeFile(path.join(dstLibsDir, "x86", "libtbxml.so")));
+ files.push(removeFile(path.join(dstLibsDir, "x86_64", "libtbxml.so")));
+
+ Q.all(files).then(function() {
+ resolve();
+ });
+ });
+ });
+
+};

MODIFY
www/MarkerCluster.js
www/MarkerCluster.js
@@ -168,14 +168,18 @@ var MarkerCluster = function(map, markerClusterId, markerClusterOptions, _exec)
if (skipRedraw) {
return;
}
- self.redraw(true);
+ self.redraw({
+ force: true
+ });
};
self.addMarkers = function(markers) {
if (utils.isArray(markers) || Array.isArray(markers)) {
for (var i = 0; i < markers.length; i++) {
self.addMarker(markers[i], true);
}
- self.redraw(true);
+ self.redraw({
+ force: true
+ });
}
};
@@ -192,7 +196,9 @@ var MarkerCluster = function(map, markerClusterId, markerClusterOptions, _exec)
sel.redraw.call(self);
});
- self.redraw.call(self, true);
+ self.redraw.call(self, {
+ force: true
+ });
if (self.debug) {
self.debugTimer = setInterval(function() {

Create install_libs.js and uninstall_libs.js for cordova-android@7