fix: (Android) Using setOptions() prompts for user location.
MODIFY
package.json
package.json
{
"name": "cordova-plugin-googlemaps",
- "version": "2.5.0-beta-20181016-1830",
+ "version": "2.5.0",
"description": "Google Maps native SDK for Android and iOS, and Google Maps JavaScript API v3 for browser.",
"cordova": {
"id": "cordova-plugin-googlemaps",

MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.5.0-beta-20181016-1830" 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.5.0-beta-20181017-1707" 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" />
<asset src="www/promise-7.0.4.min.js.map" target="promise-7.0.4.min.js.map" />

MODIFY
src/android/plugin/google/maps/PluginMap.java
src/android/plugin/google/maps/PluginMap.java
@@ -1804,7 +1804,23 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
*/
public void setMyLocationEnabled(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
+ final JSONObject params = args.getJSONObject(0);
+ Boolean isMyLocationEnabled = false;
+ if (params.has("myLocation")) {
+ //Log.d(TAG, "--->myLocation = " + params.getBoolean("myLocation"));
+ isMyLocationEnabled = params.getBoolean("myLocation");
+ }
+
+ Boolean isMyLocationButtonEnabled = false;
+ if (params.has("myLocationButton")) {
+ //Log.d(TAG, "--->myLocationButton = " + params.getBoolean("myLocationButton"));
+ isMyLocationButtonEnabled = params.getBoolean("myLocationButton");
+ }
// Request geolocation permission.
+ if (!isMyLocationButtonEnabled && !isMyLocationEnabled) {
+ callbackContext.success();
+ return;
+ }
boolean locationPermission = PermissionChecker.checkSelfPermission(cordova.getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
//Log.d(TAG, "---> setMyLocationEnabled, hasPermission = " + locationPermission);
@@ -1832,7 +1848,6 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
}
}
- final JSONObject params = args.getJSONObject(0);
this.activity.runOnUiThread(new Runnable() {
@SuppressLint("MissingPermission")

fix: (Android) Using setOptions() prompts for user location. #2475