Change the class name from PluginGeolocation to PluginLocationService
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.2.0-beta-20180126-1119" 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.0-beta-20180126-1512" 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 />
<js-module name="poly" src="www/poly.js">
<runs />
</js-module>
- <js-module name="pgmGeocoder" src="www/Geocoder.js">
+ <js-module name="Geocoder" src="www/Geocoder.js">
<runs />
</js-module>
- <js-module name="pgmGeolocation" src="www/Geolocation.js">
+ <js-module name="LocationService" src="www/LocationService.js">
<runs />
</js-module>
<js-module name="Map" src="www/Map.js">
@@ -158,11 +158,11 @@ The native map view is faster, use less network usage, display 3D views, and eve
<feature name="KmlOverlay">
<param name="android-package" value="plugin.google.maps.PluginKmlOverlay" />
</feature>
- <feature name="pgmGeocoder">
+ <feature name="Geocoder">
<param name="android-package" value="plugin.google.maps.PluginGeocoder" />
</feature>
- <feature name="pgmGeolocation">
- <param name="android-package" value="plugin.google.maps.PluginGeolocation" />
+ <feature name="LocationService">
+ <param name="android-package" value="plugin.google.maps.PluginLocationService" />
</feature>
<feature name="Environment">
<param name="android-package" value="plugin.google.maps.Environment" />
@@ -182,7 +182,7 @@ The native map view is faster, use less network usage, display 3D views, and eve
<source-file src="src/android/plugin/google/maps/MyPluginInterface.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/PluginGeolocation.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" />
@@ -229,6 +229,8 @@ The native map view is faster, use less network usage, display 3D views, and eve
</config-file>
<resource-file src="src/android/res/layout/dummy_infowindow.xml" target="res/layout/dummy_infowindow.xml"/>
+ <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.
@@ -263,11 +265,11 @@ The native map view is faster, use less network usage, display 3D views, and eve
<feature name="Environment">
<param name="ios-package" value="Environment" />
</feature>
- <feature name="pgmGeocoder">
+ <feature name="Geocoder">
<param name="ios-package" value="PluginGeocoder" />
</feature>
- <feature name="pgmGeolocation">
- <param name="ios-package" value="PluginGeolocation" />
+ <feature name="LocationService">
+ <param name="ios-package" value="PluginLocationService" />
</feature>
<feature name="Map">
<param name="ios-package" value="PluginMap" />
@@ -304,8 +306,8 @@ The native map view is faster, use less network usage, display 3D views, and eve
<source-file src="src/ios/GoogleMaps/PluginCircle.m" />
<header-file src="src/ios/GoogleMaps/PluginGeocoder.h" />
<source-file src="src/ios/GoogleMaps/PluginGeocoder.m" />
- <header-file src="src/ios/GoogleMaps/PluginGeolocation.h" />
- <source-file src="src/ios/GoogleMaps/PluginGeolocation.m" />
+ <header-file src="src/ios/GoogleMaps/PluginLocationService.h" />
+ <source-file src="src/ios/GoogleMaps/PluginLocationService.m" />
<header-file src="src/ios/GoogleMaps/Environment.h" />
<source-file src="src/ios/GoogleMaps/Environment.m" />
<header-file src="src/ios/GoogleMaps/CordovaGoogleMaps.h" />

RENAME
src/android/plugin/google/maps/PluginGeolocation.java
src/android/plugin/google/maps/PluginLocationService.java
@@ -43,9 +43,9 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-public class PluginGeolocation extends CordovaPlugin {
+public class PluginLocationService extends CordovaPlugin {
private Activity activity;
- private final String TAG = "PluginGeolocation";
+ private final String TAG = "PluginLocationService";
private HashMap<String, Bundle> bufferForLocationDialog = new HashMap<String, Bundle>();
private final int ACTIVITY_LOCATION_DIALOG = 0x7f999900; // Invite the location dialog using Google Play Services
@@ -74,7 +74,7 @@ public class PluginGeolocation extends CordovaPlugin {
public void run() {
try {
if ("getMyLocation".equals(action)) {
- PluginGeolocation.this.getMyLocation(args, callbackContext);
+ PluginLocationService.this.getMyLocation(args, callbackContext);
}
} catch (JSONException e) {
@@ -146,7 +146,7 @@ public class PluginGeolocation extends CordovaPlugin {
@Override
public void onConnected(Bundle connectionHint) {
Log.d(TAG, "===> onConnected");
- PluginGeolocation.this.sendNoResult(callbackContext);
+ PluginLocationService.this.sendNoResult(callbackContext);
_checkLocationSettings(isHigh, callbackContext);
}
@@ -221,11 +221,11 @@ public class PluginGeolocation extends CordovaPlugin {
int hashCode = bundle.hashCode();
bufferForLocationDialog.put("bundle_" + hashCode, bundle);
- PluginGeolocation.this.sendNoResult(callbackContext);
+ PluginLocationService.this.sendNoResult(callbackContext);
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult().
- cordova.setActivityResultCallback(PluginGeolocation.this);
+ cordova.setActivityResultCallback(PluginLocationService.this);
status.startResolutionForResult(cordova.getActivity(), hashCode);
} catch (IntentSender.SendIntentException e) {
// Show the dialog that is original version of this plugin.
@@ -271,10 +271,10 @@ public class PluginGeolocation extends CordovaPlugin {
int hashCode = bundle.hashCode();
bufferForLocationDialog.put("bundle_" + hashCode, bundle);
- PluginGeolocation.this.sendNoResult(callbackContext);
+ PluginLocationService.this.sendNoResult(callbackContext);
//Launch settings, allowing user to make a change
- cordova.setActivityResultCallback(PluginGeolocation.this);
+ cordova.setActivityResultCallback(PluginLocationService.this);
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
activity.startActivityForResult(intent, hashCode);
}
@@ -341,7 +341,7 @@ public class PluginGeolocation extends CordovaPlugin {
if (!isRetry) {
Toast.makeText(activity, "Waiting for location...", Toast.LENGTH_SHORT).show();
- PluginGeolocation.this.sendNoResult(callbackContext);
+ PluginLocationService.this.sendNoResult(callbackContext);
// Retry
Handler handler = new Handler();

MODIFY
src/android/plugin/google/maps/PluginMap.java
src/android/plugin/google/maps/PluginMap.java
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.RectF;
@@ -98,7 +99,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
private boolean isDragging = false;
//public final ConcurrentHashMap<String, Object> objects = new ConcurrentHashMap<String, Object>();
public final ObjectCache objects = new ObjectCache();
- private View myLocationButton;
+ private ImageView dummyMyLocationButton;
@@ -230,22 +231,30 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
@Override
public void onMapReady(GoogleMap googleMap) {
- myLocationButton = new View(activity);
+ dummyMyLocationButton = new ImageView(activity);
FrameLayout.LayoutParams lParams = new FrameLayout.LayoutParams((int)(48 * density), (int)(48 * density));
lParams.gravity = Gravity.RIGHT;
lParams.rightMargin = (int)(6 * density);
lParams.topMargin = (int)(6 * density);
lParams.leftMargin = 0;
- myLocationButton.setClickable(true);
- myLocationButton.setVisibility(View.GONE);
- myLocationButton.setLayoutParams(lParams);
- myLocationButton.setOnClickListener(new View.OnClickListener() {
+ dummyMyLocationButton.setClickable(true);
+ dummyMyLocationButton.setAlpha(0.75f);
+ dummyMyLocationButton.setVisibility(View.GONE);
+ dummyMyLocationButton.setLayoutParams(lParams);
+
+ int buttonImgId = PluginUtil.getAppResource(cordova.getActivity(), "dummy_my_location_button", "drawable");
+ dummyMyLocationButton.setImageBitmap(BitmapFactory.decodeResource(activity.getResources(), buttonImgId));
+
+ int shadowXmlId = PluginUtil.getAppResource(cordova.getActivity(), "dummy_mylocation_button_shadow", "drawable");
+ dummyMyLocationButton.setBackground(activity.getResources().getDrawable(shadowXmlId));
+
+ dummyMyLocationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PluginMap.this.onMyLocationButtonClick();
}
});
- mapView.addView(myLocationButton);
+ mapView.addView(dummyMyLocationButton);
map = googleMap;
projection = map.getProjection();
@@ -290,10 +299,10 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
}
map.setPadding(left, top, right, bottom);
- FrameLayout.LayoutParams lParams2 = (FrameLayout.LayoutParams) myLocationButton.getLayoutParams();
+ FrameLayout.LayoutParams lParams2 = (FrameLayout.LayoutParams) dummyMyLocationButton.getLayoutParams();
lParams2.rightMargin = right + (int)(5 * density);
lParams2.topMargin = top + (int)(5 * density);
- myLocationButton.setLayoutParams(lParams2);
+ dummyMyLocationButton.setLayoutParams(lParams2);
}
@@ -1223,10 +1232,10 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
}
map.setPadding(left, top, right, bottom);
- FrameLayout.LayoutParams lParams2 = (FrameLayout.LayoutParams) myLocationButton.getLayoutParams();
+ FrameLayout.LayoutParams lParams2 = (FrameLayout.LayoutParams) dummyMyLocationButton.getLayoutParams();
lParams2.rightMargin = right + (int)(5 * density);
lParams2.topMargin = top + (int)(5 * density);
- myLocationButton.setLayoutParams(lParams2);
+ dummyMyLocationButton.setLayoutParams(lParams2);
}
if (preferences.has("zoom")) {
@@ -1670,8 +1679,8 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
public void onRequestPermissionResult(int requestCode, String[] permissions,
int[] grantResults) throws JSONException {
- synchronized (PluginGeolocation.semaphore) {
- PluginGeolocation.semaphore.notify();
+ synchronized (PluginLocationService.semaphore) {
+ PluginLocationService.semaphore.notify();
}
}
@@ -1692,9 +1701,9 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
//_saveArgs = args;
//_saveCallbackContext = callbackContext;
cordova.requestPermissions(this, callbackContext.hashCode(), new String[]{"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"});
- synchronized (PluginGeolocation.semaphore) {
+ synchronized (PluginLocationService.semaphore) {
try {
- PluginGeolocation.semaphore.wait();
+ PluginLocationService.semaphore.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -1712,17 +1721,24 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
@Override
public void run() {
try {
+ Boolean isMyLocationEnabled = false;
+ if (params.has("myLocation")) {
+ isMyLocationEnabled = params.getBoolean("myLocation");
+ map.setMyLocationEnabled(isMyLocationEnabled);
+ }
+
+ Boolean isMyLocationButtonEnabled = false;
if (params.has("myLocationButton")) {
- Boolean isMyLocationButtonEnabled = params.getBoolean("myLocationButton");
+ isMyLocationButtonEnabled = params.getBoolean("myLocationButton");
map.getUiSettings().setMyLocationButtonEnabled(isMyLocationButtonEnabled);
- myLocationButton.setVisibility(isMyLocationButtonEnabled ? View.INVISIBLE : View.GONE);
}
-
-
- if (params.has("myLocation")) {
- Boolean isMyLocationEnabled = params.getBoolean("myLocation");
- map.setMyLocationEnabled(isMyLocationEnabled);
+ //Log.d(TAG, "--->isMyLocationButtonEnabled = " + isMyLocationButtonEnabled + ", isMyLocationEnabled = " + isMyLocationEnabled);
+ if (!isMyLocationEnabled && isMyLocationButtonEnabled) {
+ dummyMyLocationButton.setVisibility(View.VISIBLE);
+ } else {
+ dummyMyLocationButton.setVisibility(View.GONE);
}
+
} catch (Exception e) {
e.printStackTrace();
}
@@ -2051,10 +2067,10 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
public void run() {
map.setPadding(left, top, right, bottom);
- FrameLayout.LayoutParams lParams2 = (FrameLayout.LayoutParams) myLocationButton.getLayoutParams();
+ FrameLayout.LayoutParams lParams2 = (FrameLayout.LayoutParams) dummyMyLocationButton.getLayoutParams();
lParams2.rightMargin = right + (int)(5 * density);
lParams2.topMargin = top + (int)(5 * density);
- myLocationButton.setLayoutParams(lParams2);
+ dummyMyLocationButton.setLayoutParams(lParams2);
callbackContext.success();
}
@@ -2471,7 +2487,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
@Override
public void onMyLocationClick(@NonNull Location location) {
- PluginGeolocation.setLastLocation(location);
+ PluginLocationService.setLastLocation(location);
try {
JSONObject result = PluginUtil.location2Json(location);
jsCallback(String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s',{evtName: 'my_location_click', callback:'_onMapEvent', args: [%s]});}", mapId, result.toString(0)));

ADD
src/android/res/drawable/dummy_my_location_button.png
src/android/res/drawable/dummy_my_location_button.png
Binary files /dev/null and b/src/android/res/drawable/dummy_my_location_button.png differ

ADD
src/android/res/drawable/dummy_mylocation_button_shadow.xml
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <!-- Drop Shadow Stack -->
+ <item>
+ <shape>
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp" />
+
+ <solid android:color="#00CCCCCC" />
+
+ <corners android:radius="1dp" />
+ </shape>
+ </item>
+ <item>
+ <shape>
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp" />
+
+ <solid android:color="#10CCCCCC" />
+
+ <corners android:radius="1dp" />
+ </shape>
+ </item>
+ <item>
+ <shape>
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp" />
+
+ <solid android:color="#20CCCCCC" />
+
+ <corners android:radius="1dp" />
+ </shape>
+ </item>
+ <item>
+ <shape>
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp" />
+
+ <solid android:color="#30CCCCCC" />
+
+ <corners android:radius="1dp" />
+ </shape>
+ </item>
+ <item>
+ <shape>
+ <padding
+ android:bottom="1dp"
+ android:left="1dp"
+ android:right="1dp"
+ android:top="1dp" />
+
+ <solid android:color="#50CCCCCC" />
+
+ <corners android:radius="1dp" />
+ </shape>
+ </item>
+
+ <!-- Background -->
+ <item>
+ <shape>
+ <solid android:color="#FCFFFFFF" />
+
+ <corners android:radius="1dp" />
+ </shape>
+ </item>
+
+</layer-list>

RENAME
src/ios/GoogleMaps/PluginGeolocation.h
src/ios/GoogleMaps/PluginLocationService.h
//
-// CordovaGoogleMaps.h
+// PluginLocationService.h
// cordova-googlemaps-plugin v2
//
// Created by Masashi Katsumata.
#import <Cordova/CDV.h>
#import <GoogleMaps/GoogleMaps.h>
-@interface PluginGeolocation : CDVPlugin<CLLocationManagerDelegate>
+@interface PluginLocationService : CDVPlugin<CLLocationManagerDelegate>
@property (nonatomic, strong) NSMutableDictionary *lastResult;
@property (nonatomic, strong) CLLocation *lastLocation;

RENAME
src/ios/GoogleMaps/PluginGeolocation.m
src/ios/GoogleMaps/PluginLocationService.m
//
-// CordovaGoogleMaps.m
+// PluginLocationService.m
// cordova-googlemaps-plugin v2
//
// Created by Masashi Katsumata.
//
//
-#import "PluginGeolocation.h"
+#import "PluginLocationService.h"
-@implementation PluginGeolocation
+@implementation PluginLocationService
- (void)pluginInitialize
{

RENAME
www/Geolocation.js
www/LocationService.js
/*****************************************************************************
- * Geolocation class
+ * LocationService class
*****************************************************************************/
var argscheck = require('cordova/argscheck'),
utils = require('cordova/utils'),
BaseClass = require('./BaseClass');
var exec;
-function Geolocation(_exec) {
+function LocationService(_exec) {
exec = _exec;
BaseClass.apply(this);
}
-utils.extend(Geolocation, BaseClass);
+utils.extend(LocationService, BaseClass);
-Geolocation.prototype.getMyLocation = function(params, success_callback, error_callback) {
+LocationService.prototype.getMyLocation = function(params, success_callback, error_callback) {
var self = this;
var args = [params || {}, success_callback || null, error_callback];
if (typeof args[0] === "function") {
@@ -38,12 +38,12 @@ Geolocation.prototype.getMyLocation = function(params, success_callback, error_c
};
exec.call({
_isReady: true
- }, successHandler, errorHandler, 'pgmGeolocation', 'getMyLocation', [params], {sync: true});
+ }, successHandler, errorHandler, 'LocationService', 'getMyLocation', [params], {sync: true});
};
/**
// TODO:
-Geolocation.prototype.followMyPosition = function(params, success_callback, error_callback) {
+LocationService.prototype.followMyPosition = function(params, success_callback, error_callback) {
var self = this;
var args = [params || {}, success_callback || null, error_callback];
if (typeof args[0] === "function") {
@@ -67,7 +67,7 @@ Geolocation.prototype.followMyPosition = function(params, success_callback, erro
}, successHandler, errorHandler, 'CordovaGoogleMaps', 'followMyPosition', [params], {sync: true});
};
-Geolocation.prototype.clearFollowing = function() {
+LocationService.prototype.clearFollowing = function() {
var self = this;
self.off('currentPosition_changed');
exec.call({
@@ -76,4 +76,4 @@ Geolocation.prototype.clearFollowing = function() {
};
**/
-module.exports = Geolocation;
+module.exports = LocationService;

MODIFY
www/Map.js
www/Map.js
@@ -274,7 +274,7 @@ Map.prototype.setOptions = function(options) {
};
Map.prototype.getMyLocation = function(params, success_callback, error_callback) {
- plugin.google.maps.Geolocation.getMyLocation(params, success_callback, error_callback);
+ plugin.google.maps.LocationService.getMyLocation(params, success_callback, error_callback);
};
Map.prototype.setCameraTarget = function(latLng) {

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -70,8 +70,8 @@ if (!cordova) {
var encoding = require('./encoding');
var spherical = require('./spherical');
var poly = require('./poly');
- var Geocoder = require('./pgmGeocoder');
- var Geolocation = require('./pgmGeolocation');
+ var Geocoder = require('./Geocoder');
+ var LocationService = require('./LocationService');
var Environment = require('./Environment');
var MapTypeId = require('./MapTypeId');
@@ -643,7 +643,7 @@ if (!cordova) {
/*****************************************************************************
* Name space
*****************************************************************************/
- var singletonGeolocation = new Geolocation(execCmd);
+ var singletonLocationService = new LocationService(execCmd);
module.exports = {
event: event,
Animation: {
@@ -858,7 +858,7 @@ if (!cordova) {
MapTypeId: MapTypeId,
environment: Environment,
Geocoder: Geocoder,
- Geolocation: singletonGeolocation,
+ LocationService: singletonLocationService,
geometry: {
encoding: encoding,
spherical: spherical,

Change the class name from PluginGeolocation to PluginLocationService