From 1e27920751a74fb015dc81618e78e369f3d5b1fa Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Mon, 30 Mar 2020 23:46:17 -0700 Subject: [PATCH 1/6] Ready for v2.7.0 --- README.md | 148 ++++++++++----------------------------------------- package.json | 2 +- plugin.xml | 2 +- 3 files changed, 31 insertions(+), 121 deletions(-) diff --git a/README.md b/README.md index 268f3fff3..37cb91e1a 100644 --- a/README.md +++ b/README.md @@ -37,81 +37,11 @@ ## Quick install - - *Stable version(npm)* - ``` - $> cordova plugin add cordova-plugin-googlemaps - ``` - - - *Development version(beta version)* - ``` - $> cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps#multiple_maps - ``` - -## PhoneGap Build settings - - ```xml - - - - - - ``` - -## Install optional variables - - - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-android.png) **PLAY_SERVICES_VERSION = (15.0.1)**
- The Google Play Services SDK version. - _You need to specify the same version number with all other plugins._ - Check out the latest version [here](https://developers.google.com/android/guides/releases). - - - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-android.png) **ANDROID_SUPPORT_V4_VERSION = (27.1.1)**
- This plugin requires the Android support library v4. - _The minimum version is 24.1.0._ - Check out the latest version [here](https://developer.android.com/topic/libraries/support-library/revisions.html). - - - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-ios.png) **LOCATION_WHEN_IN_USE_DESCRIPTION**
- This message is displayed when your application requests **LOCATION PERMISSION for only necessary times**. - - - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-ios.png) **LOCATION_ALWAYS_USAGE_DESCRIPTION**
- This message is displayed when your application requests **LOCATION PERMISSION for always**. - ---------------------------------------------------------------------------------------------------------- - -## Browser platform - - We support browser platform now! - You can develop your application with browser, then run it! - At the end of development, you can upload the html files to your server, or run it on Android or iOS devices. - - ``` - $> cordova run browser ``` - - If you use [ionic framework](https://ionicframework.com/), it supports `live-reload`. - - ``` - $> ionic cordova run browser -l + $> cordova plugin add cordova-plugin-googlemaps ``` - If you want to use `live-reload`, but you don't want to use other framework or without framework, - [cordova-plugin-browsersync](https://www.npmjs.com/package/cordova-plugin-browsersync) is useful. - - ``` - $> cordova plugin add cordova-plugin-browsersync - - $> cordova run (browser/android/ios) -- --live-reload - ``` - - -### API key (Android and iOS platforms) - - As of v2.6.0, you need to specify your API keys in `config.xml` file instead of `--variable`. - This allows you to change your API keys for anytime without reinstallation. - - Please pay attention the variable names are changed. +Then set your Google Maps API keys into your `config.xml` (Android / iOS). ```xml @@ -120,11 +50,7 @@ ``` -### API key (Browser platform) - - In the browser platform, the maps plugin uses [Google Maps JavaScript API v3](https://developers.google.com/maps/documentation/javascript/) - - You need to set **two API keys for Google Maps JavaScript API v3**. +For browser platform, ```js // If your app runs this program on browser, @@ -136,7 +62,7 @@ // plugin.google.maps.environment.setEnv({ 'API_KEY_FOR_BROWSER_RELEASE': '(YOUR_API_KEY_IS_HERE)', - 'API_KEY_FOR_BROWSER_DEBUG': '' + 'API_KEY_FOR_BROWSER_DEBUG': '' // optional }); // Create a Google Maps native view under the map_canvas div. @@ -144,54 +70,36 @@ ``` -### Why **two API keys**? - - `JavaScript` code is `text code`. Even if you do obfuscation, it's still readable finally. - In order to protect your API key, you need to set `Key restriction` for these keys. - - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/api_key_restrictions.png) +## PhoneGap Build settings - If you don't set API key, the maps plugin still work with `development mode`. + ```xml + - ```js - plugin.google.maps.environment.setEnv({ - 'API_KEY_FOR_BROWSER_RELEASE': '(YOUR_API_KEY_IS_HERE)', - 'API_KEY_FOR_BROWSER_DEBUG': '' // If key is empty or unset, - // the maps plugin runs under the development mode. - }); + + + ``` - - -### Which browser supported? - - Modern browsers should work without any problem. - - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/modern_browsers.png) - Internet Explorer 11 might work. We don't confirm all features, but basic features work. +## Install optional variables (config.xml) -### Behavior differences - - `Google Maps JavaScript API v3` is completely different ecosystem with `Google Maps Android API` and `Google Maps SDK for iOS`. - - `Google Maps JavaScript API v3` : - - **can't** draw 3D building, - - **does't work** if offline, - - **can't** map rotation, - - etc... - - In the browser platform, the maps plugin works almost the same behaviors as native platforms(Android, and iOS), - but not exactly the same behaviors. - So don't expect too much. + - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-android.png) **PLAY_SERVICES_VERSION = (15.0.1)**
+ The Google Play Services SDK version. + _You need to specify the same version number with all other plugins._ + Check out the latest version [here](https://developers.google.com/android/guides/releases). -### Touch mechanism difference + - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-android.png) **ANDROID_SUPPORT_V4_VERSION = (27.1.1)**
+ This plugin requires the Android support library v4. + _The minimum version is 24.1.0._ + Check out the latest version [here](https://developer.android.com/topic/libraries/support-library/revisions.html). - As you may know, [this plugin displays native Google Maps view under the browser in Android and iOS](#how-does-this-plugin-work-android-ios). - However this plugin displays as `normal HTML element` in browser platform. + - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-ios.png) **LOCATION_WHEN_IN_USE_DESCRIPTION**
+ This message is displayed when your application requests **LOCATION PERMISSION for only necessary times**. - Because of this, touch behavior is different. - The maps plugin does not hook the touch position, do not set `background: transparent`, ... etc. - But if you use this plugin as normal behavior, you don't need to consider about this. + - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-ios.png) **LOCATION_ALWAYS_USAGE_DESCRIPTION**
+ This message is displayed when your application requests **LOCATION PERMISSION for always**. --------------------------------------------------------------------------------------------------------- @@ -206,6 +114,7 @@ ## Release Notes - **v2.7.0** - Re-adoption: cordova-plugin-googlemaps-sdk dependency + - Important update: No longer support `UIWebView` on iOS. `WKWebView` only. - Fix: (iOS) Can't load image files from local host on ionic 4 / 5 - Update: (Android) prevent null pointer error in AsyncLoadImage.java - Fix: Css animation interference when call setDiv and there is a push/pop page @@ -225,7 +134,8 @@ - Remove promise-7.0.4-min.js.map - Fix: (iOS) bug fix: App crashes if "bearing" property is "" - Fix: HTMLColor2RGBA() converts to incorrect value - - Fix: (Android) Can't load marker image from the Ineternet + - Fix: (Android) Can't load marker image from the Internet + - many bug fixes... - **v2.6.2** - Fix: (Android) build error diff --git a/package.json b/package.json index 6c03090e7..45044e755 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-googlemaps", - "version": "2.7.0-20200330-2338", + "version": "2.7.0", "description": "Google Maps native SDK for Android and iOS, and Google Maps JavaScript API v3 for browser.", "cordova": { "id": "cordova-plugin-googlemaps", diff --git a/plugin.xml b/plugin.xml index 4d0024f79..78c2c9c8d 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + cordova-plugin-googlemaps From d015687c2f959f4b82045dd22c0eff5ba90c5f75 Mon Sep 17 00:00:00 2001 From: wf9a5m75 Date: Thu, 9 Apr 2020 15:10:01 -0700 Subject: [PATCH 2/6] prepare for v2.7.1 --- README.md | 20 +++++--------------- package.json | 2 +- plugin.xml | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 37cb91e1a..4d4d973ec 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Cordova GoogleMaps plugin for Android, iOS and Browser v2.7.0 +# Cordova GoogleMaps plugin for Android, iOS and Browser v2.7.1 | Download | Build test (multiple_maps branch)| |----------|---------------------------| @@ -112,6 +112,10 @@ For browser platform, --------------------------------------------------------------------------------------------------------- ## Release Notes + + - **v2.7.1** + - Fix: (iOS) UiWebView references present in v2.7.0 + - **v2.7.0** - Re-adoption: cordova-plugin-googlemaps-sdk dependency - Important update: No longer support `UIWebView` on iOS. `WKWebView` only. @@ -137,20 +141,6 @@ For browser platform, - Fix: (Android) Can't load marker image from the Internet - many bug fixes... - - **v2.6.2** - - Fix: (Android) build error - - - **v2.6.1** - - Fix: (Android) Conflicting with `OneSignal-Cordova-SDK` - - Fix: (iOS) App crashes when marker url isn't valid. - - - **v2.6.0** - - Fix: Can not install to Cordova 9.0 project - - Fix: (Android) `ConcurrentModificationException` error at `onStop` - - Fix: (Android) Polygon becomes visible when you run `setPoints()` to invisible polygon - - Fix: (Android/iOS) TileOverlay does not work when your app runs on `file:` protocol with ionic. - - Update: (iOS) Specify the Google Maps SDK version as `=> 3.1.0`. Please use `cordova-ios@5.0.0` or above, otherwise modify `platform/ios/Podfile`. - - Add: (Android/iOS) API Key mechanism --------------------------------------------------------------------------------------------------------- diff --git a/package.json b/package.json index 45044e755..bc6c54e48 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-googlemaps", - "version": "2.7.0", + "version": "2.7.1", "description": "Google Maps native SDK for Android and iOS, and Google Maps JavaScript API v3 for browser.", "cordova": { "id": "cordova-plugin-googlemaps", diff --git a/plugin.xml b/plugin.xml index 78c2c9c8d..1a2c801c5 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + cordova-plugin-googlemaps From de0bee2d8bd2d3f6232741fbf84497a49435c408 Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Fri, 22 May 2020 09:48:23 -0700 Subject: [PATCH 3/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d4d973ec..dd66aebfd 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ For browser platform, ## Install optional variables (config.xml) - - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-android.png) **PLAY_SERVICES_VERSION = (15.0.1)**
+ - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-android.png) **GOOGLE_MAPS_PLAY_SERVICES_VERSION = (16.0.1)**
The Google Play Services SDK version. _You need to specify the same version number with all other plugins._ Check out the latest version [here](https://developers.google.com/android/guides/releases). From 420e90705c48c135aa3f8c0cc85b3ad7325c429e Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Mon, 17 Aug 2020 15:34:51 -0700 Subject: [PATCH 4/6] Prevent crash at onStop Probably the bug of the Google Maps SDK for Android v3 beta --- src/android/plugin/google/maps/PluginMap.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/android/plugin/google/maps/PluginMap.java b/src/android/plugin/google/maps/PluginMap.java index a3d379f0e..b4bde52e4 100644 --- a/src/android/plugin/google/maps/PluginMap.java +++ b/src/android/plugin/google/maps/PluginMap.java @@ -497,6 +497,11 @@ public void onCameraIdle() { }); } + /* + //*************************************************************************** + // Google Maps SDK for Android v3 beta causes crash for these processes. + // Tmporally commented out + //*************************************************************************** @Override public void onStart() { super.onStart(); @@ -531,6 +536,7 @@ public void onResume(boolean multitasking) { } //mapCtrl.mPluginLayout.addPluginOverlay(PluginMap.this); } + */ private class AdjustInitCamera implements Runnable { private JSONObject mParams; From bdb7af4730857a6b51662a8cfd180f6c5a3dce35 Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Mon, 17 Aug 2020 15:35:52 -0700 Subject: [PATCH 5/6] Revert --- src/android/plugin/google/maps/PluginMap.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/android/plugin/google/maps/PluginMap.java b/src/android/plugin/google/maps/PluginMap.java index b4bde52e4..a3d379f0e 100644 --- a/src/android/plugin/google/maps/PluginMap.java +++ b/src/android/plugin/google/maps/PluginMap.java @@ -497,11 +497,6 @@ public void onCameraIdle() { }); } - /* - //*************************************************************************** - // Google Maps SDK for Android v3 beta causes crash for these processes. - // Tmporally commented out - //*************************************************************************** @Override public void onStart() { super.onStart(); @@ -536,7 +531,6 @@ public void onResume(boolean multitasking) { } //mapCtrl.mPluginLayout.addPluginOverlay(PluginMap.this); } - */ private class AdjustInitCamera implements Runnable { private JSONObject mParams; From 89d1cfedd72de623b34f32c3bffd1c54f1c70e27 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 11 Dec 2020 15:22:58 +0100 Subject: [PATCH 6/6] fix on tap on polyline --- src/ios/GoogleMaps/PluginMapViewController.m | 32 ++++++++++++++++---- src/ios/GoogleMaps/PluginPolyline.m | 6 ++-- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/ios/GoogleMaps/PluginMapViewController.m b/src/ios/GoogleMaps/PluginMapViewController.m index 4cf535280..c54fec1a9 100644 --- a/src/ios/GoogleMaps/PluginMapViewController.m +++ b/src/ios/GoogleMaps/PluginMapViewController.m @@ -64,12 +64,33 @@ - (void)mapView:(GMSMapView *)mapView didTapMyLocation:(CLLocationCoordinate2D)l [self execJS:jsString]; } +- (void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay { + NSLog(@"--> key = %@, did tap an overlay", overlay.title); + + if (![overlay.title hasPrefix:@"polyline_"]) { + return; + } + + NSArray *tmp = [overlay.title componentsSeparatedByString:@"_"]; + NSString *eventName = [NSString stringWithFormat:@"%@_click", [tmp objectAtIndex:0]]; + NSString *propertyId = [NSString stringWithFormat:@"polyline_property_%@", [tmp objectAtIndex:1]]; + NSDictionary *properties = [self.objects objectForKey: propertyId]; + + if (!properties) { + NSLog(@"--> object properties not found for key=%@", propertyId); + return; + } + + GMSCoordinateBounds *bounds = (GMSCoordinateBounds *)[properties objectForKey:@"bounds"]; + + [self triggerOverlayEvent: eventName overlayId: overlay.title coordinate: bounds.center]; +} + /** * @callback the my location button is clicked. */ - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate { - if (self.activeMarker) { /* NSString *clusterId_markerId =[NSString stringWithFormat:@"%@", self.activeMarker.userData]; @@ -205,7 +226,7 @@ - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D continue; } - if ([key hasPrefix:@"polyline_"]) { + /*if ([key hasPrefix:@"polyline_"]) { geodesic = (NSNumber *)[properties objectForKey:@"geodesic"]; path = (GMSPath *)[properties objectForKey:@"mutablePath"]; if ([geodesic boolValue] == YES) { @@ -216,14 +237,14 @@ - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D continue; } } else { - touchPoint = [PluginUtil isPointOnTheLine:path coordinate:coordinate projection:self.map.projection]; - if (CLLocationCoordinate2DIsValid(touchPoint)) { + touchPoint = [PluginUtil isPointOnTheLine:path coordinate:coordinate projection:self.map.projection]; + if (CLLocationCoordinate2DIsValid(touchPoint)) { maxZIndex = zIndex; hitKey = [key stringByReplacingOccurrencesOfString:@"_property" withString:@""]; continue; } } - } + }*/ if ([key hasPrefix:@"polygon_"]) { path = (GMSPath *)[properties objectForKey:@"mutablePath"]; @@ -235,7 +256,6 @@ - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D } } - if ([key hasPrefix:@"circle_"]) { key = [key stringByReplacingOccurrencesOfString:@"_property" withString:@""]; GMSCircle *circle = (GMSCircle *)[self.objects objectForKey:key]; diff --git a/src/ios/GoogleMaps/PluginPolyline.m b/src/ios/GoogleMaps/PluginPolyline.m index 3846952b2..e2cfe2f32 100644 --- a/src/ios/GoogleMaps/PluginPolyline.m +++ b/src/ios/GoogleMaps/PluginPolyline.m @@ -102,12 +102,12 @@ -(void)create:(CDVInvokedUrlCommand *)command // Since this plugin provide own click detection, // disable default clickable feature. - polyline.tappable = NO; + polyline.tappable = [[json valueForKey:@"clickable"] boolValue]; NSString *id = [NSString stringWithFormat:@"polyline_%@", idBase]; [self.mapCtrl.objects setObject:polyline forKey: id]; polyline.title = id; - + // Run the below code on background thread. [self.mapCtrl.executeQueue addOperationWithBlock:^{ @@ -121,7 +121,7 @@ -(void)create:(CDVInvokedUrlCommand *)command // Keep the properties //--------------------------- NSString *propertyId = [NSString stringWithFormat:@"polyline_property_%@", idBase]; - + // points NSMutableDictionary *properties = [[NSMutableDictionary alloc] init]; [properties setObject:mutablePath forKey:@"mutablePath"];