Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple maps #2929

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
079036a
- Add: (Android/iOS/Browser) `mapOptions.preferences.gestureBounds`
wf9a5m75 Apr 30, 2020
458d2df
still working on.
wf9a5m75 May 2, 2020
14f2e93
still working on
wf9a5m75 May 3, 2020
b0f9c23
still working on
wf9a5m75 May 3, 2020
fb024dc
still working on
wf9a5m75 May 6, 2020
017f088
still working on
wf9a5m75 May 6, 2020
de34efa
Bug fix: #fff does not become white
wf9a5m75 May 7, 2020
202c3dc
Map.setOptions() return a promise
wf9a5m75 May 7, 2020
ba43921
still working on
wf9a5m75 May 7, 2020
47fecab
- fix: (Android) mapOptions.camera.padding does not work on map.setOp…
wf9a5m75 May 8, 2020
02efa09
still working on
wf9a5m75 May 8, 2020
6b1b5da
still working on
wf9a5m75 May 8, 2020
a0f25c5
still working on
wf9a5m75 May 8, 2020
c680247
- Bug fix (android / iOS) zIndex does not work
wf9a5m75 May 9, 2020
e4297e4
Fix (Android) : mapOptions.camera does not work correctly
wf9a5m75 May 10, 2020
640101c
still working on DirectionsRenderer
wf9a5m75 May 11, 2020
7ea6cf9
still working on DirectionsRenderer
wf9a5m75 May 12, 2020
f51c21a
Fix: #2774 (browser)
wf9a5m75 May 14, 2020
8773ab3
still working on DirectionsRenderer
wf9a5m75 May 19, 2020
77ec241
still working on DirectionsRenderer
wf9a5m75 May 19, 2020
162521f
No longer ANDROID_SUPPORT_V4_VERSION option is necessary
wf9a5m75 May 19, 2020
7242938
still working on DirectionsRenderer
wf9a5m75 May 19, 2020
9a5490c
Fix: mapOptions.preferences
wf9a5m75 May 19, 2020
12fb9cf
still working on
wf9a5m75 May 19, 2020
a75dac2
Fix: map.preferences.restriction
wf9a5m75 May 19, 2020
73adf5a
(Android / iOS / browser) Add: Ability to change clickability of POI …
wf9a5m75 May 20, 2020
aee5f5b
Update: README.md
wf9a5m75 May 20, 2020
a2bab10
(Android) Fix: some property remains #2778
wf9a5m75 May 20, 2020
31116c4
Remove debug code
wf9a5m75 May 20, 2020
210b68f
(Android / iOS) Bug fix: Can not interactive with map after `map.off()`
wf9a5m75 May 20, 2020
93e3e53
(Android) bug fix: can not reset the `zoom` and `restriction` paramet…
wf9a5m75 May 20, 2020
e6342dd
Hide `__pluginDomId` and `__pluginMapId`
wf9a5m75 May 22, 2020
f722b9e
Remove tile aggressively.
wf9a5m75 May 23, 2020
ae9f15f
revert the commit
wf9a5m75 May 23, 2020
be85b94
Use `Maps SDK for Android v.3` instead of Google Play Services
wf9a5m75 May 29, 2020
3f47931
Revert "Use `Maps SDK for Android v.3` instead of Google Play Services"
wf9a5m75 May 29, 2020
885d8e5
Revert "Revert "Use `Maps SDK for Android v.3` instead of Google Play…
wf9a5m75 May 29, 2020
76055d3
still working on
wf9a5m75 May 30, 2020
c4df91b
Automatic switch dependencies for androidx
wf9a5m75 May 30, 2020
3fc504a
update version number
wf9a5m75 May 30, 2020
8cd0c25
Use cordova-androidx-build as dependency plugin
wf9a5m75 May 30, 2020
a9088cf
(Android) bug fix: Possible issue with map hit testing
wf9a5m75 Jun 1, 2020
2616d16
Fix: __pluginDomID causes error
wf9a5m75 Jul 2, 2020
f02aabf
Use "Maps SDK for Android v.3.1.0 BETA"
wf9a5m75 Jul 9, 2020
41f1be6
(iOS) Bug fix: View hierarchy does not work correctly
wf9a5m75 Jul 9, 2020
f6bef6d
Bug fix: map.setDiv() tries to change value of a readonly property #2809
wf9a5m75 Jul 10, 2020
9598dc4
Small bug fixes
wf9a5m75 Jul 10, 2020
2cdc896
Update PluginMap.java
wf9a5m75 Aug 17, 2020
6346bca
Load image from local path
chacabuk Mar 2, 2023
6cfc7a1
2.8.1 - Quito CDVCommandDelegateImpl
chacabuk Mar 25, 2024
c5a5b35
Merge branch 'master' into multiple_maps
chacabuk Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 21 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cordova GoogleMaps plugin for Android, iOS and Browser v2.7.1
# Cordova GoogleMaps plugin for Android, iOS and Browser v2.8.0

| Download | Build test (multiple_maps branch)|
|----------|---------------------------|
Expand Down Expand Up @@ -82,18 +82,15 @@ For browser platform,
<preference name="phonegap-version" value="cli-8.1.1" />
</widget>
```

## Install optional variables (config.xml)

- ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-android.png) **GOOGLE_MAPS_PLAY_SERVICES_VERSION = (16.0.1)**<br>
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)**<br>
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-android.png) **APP_COMPAT_VERSION = (1.1.0)**<br>
**PLAY_SERVICES_BASEMENT_VERSION = (17.2.1)**<br>
**PLAY_SERVICES_BASE_VERSION = (17.2.1)**<br>
**PLAY_SERVICES_GCM_VERSION = (17.0.0)**<br>
**PLAY_SERVICES_LOCATION_VERSION = (17.0.0)**<br>
**GOOGLE_MAPS_ANDROID_SDK = (maps-sdk-3.0.0-beta)**<br>
cordova-plugin-googlemaps version 2.8.0 or later uses [Maps SDK for Android v.3](https://developers.google.com/maps/documentation/android-sdk/v3-client-migration).

- ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-ios.png) **LOCATION_WHEN_IN_USE_DESCRIPTION**<br>
This message is displayed when your application requests **LOCATION PERMISSION for only necessary times**.
Expand All @@ -113,34 +110,19 @@ For browser platform,

## Release Notes

- **v2.7.1**
- Fix: (iOS) UiWebView references present in v2.7.0

- **v2.7.0**
- Re-adoption: <a href="https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk" target="_blank">cordova-plugin-googlemaps-sdk dependency</a>
- 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
- Fix: (Android/iOS/Browser) KML parser crash
- Fix: flickering and wrong rendering of some DOM elements
- Add: `map.stopAnimation()`
- Fix: can't remove map while map.animateCamera() is running
- Update: (Android) Increase cache memory size
- Update: (Android/iOS) Danish localization
- Fix: (Android) Prevent resize event after `map.setDiv(null)`
- Fix: (Android/iOS) Can not interactive with the map inside <form>
- Fix: jslint errors
- Fix: marker.setIcon crashes
- Update: Set default value range to heading and tilt
- Fix: (Android/iOS) touch detection is wrong after clicking on back button very soon.
- Fix: An error occurs when you click a marker of marker cluster #2660
- Remove promise-7.0.4-min.js.map
- Fix: (iOS) bug fix: App crashes if "bearing" property is "<null>"
- Fix: HTMLColor2RGBA() converts to incorrect value
- Fix: (Android) Can't load marker image from the Internet
- many bug fixes...

- **v2.8.0**
- Important Change: (Android)
If `android.useAndroidX=true` and `android.enableJetifier=true` are defined in `gradle.properties`,
this plugin uses [Maps SDK for Android v.3.0.0 BETA](https://developers.google.com/maps/documentation/android-sdk/v3-client-migration).
If no definition, this plugin uses `com.google.android.gms:play-services-maps`

- Add: (Android/iOS/Browser) `mapOptions.preferences.restriction` which is able to set the camera bounds.
- Add: (Android/iOS/Browser) `mapOptions.preferences.clickableIcons` which is able to be disable clicking on POI icons.
- Bug fix: (Android/iOS/Browser) `mapOptions.preferences.building` does not work.
- Add: (Android/iOS/Browser) ElevationService
- Add: (Android/iOS/Browser) DirectionsService and `map.addDirectionsRenderer()`
- Change: (Android/iOS/Browser) `map.setDiv()`, `map.setOptions()` returns `Promise`.
- Change: (Android/iOS/Browser) Hides `__pluginDomId` and `__pluginMapId` properties.

---------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-googlemaps",
"version": "2.7.1",
"version": "2.8.0-20200709-2008",
"description": "Google Maps native SDK for Android and iOS, and Google Maps JavaScript API v3 for browser.",
"cordova": {
"id": "cordova-plugin-googlemaps",
Expand Down
40 changes: 39 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-googlemaps" version="2.7.1" 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.8.1" 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">
Expand Down Expand Up @@ -62,6 +62,15 @@
<js-module name="LocationService" src="www/LocationService.js">
<runs/>
</js-module>
<js-module name="ElevationService" src="www/ElevationService.js">
<runs/>
</js-module>
<js-module name="DirectionsService" src="www/DirectionsService.js">
<runs/>
</js-module>
<js-module name="DirectionsRenderer" src="www/DirectionsRenderer.js">
<runs/>
</js-module>
<js-module name="Map" src="www/Map.js">
<runs/>
</js-module>
Expand Down Expand Up @@ -182,6 +191,12 @@
<feature name="PluginGeocoder">
<param name="android-package" value="plugin.google.maps.PluginGeocoder"/>
</feature>
<feature name="PluginElevationService">
<param name="android-package" value="plugin.google.maps.PluginElevationService"/>
</feature>
<feature name="PluginDirectionsService">
<param name="android-package" value="plugin.google.maps.PluginDirectionsService"/>
</feature>
<feature name="PluginLocationService">
<param name="android-package" value="plugin.google.maps.PluginLocationService"/>
</feature>
Expand All @@ -196,6 +211,8 @@
</feature>
</config-file>

<source-file src="src/android/plugin/google/maps/AsyncGetJsonWithURL.java" target-dir="src/plugin/google/maps"/>
<source-file src="src/android/plugin/google/maps/AsyncHttpGetInterface.java" target-dir="src/plugin/google/maps"/>
<source-file src="src/android/plugin/google/maps/AsyncLoadImage.java" target-dir="src/plugin/google/maps"/>
<source-file src="src/android/plugin/google/maps/AsyncLoadImageInterface.java" target-dir="src/plugin/google/maps"/>
<source-file src="src/android/plugin/google/maps/PluginEnvironment.java" target-dir="src/plugin/google/maps"/>
Expand All @@ -206,6 +223,8 @@
<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/PluginElevationService.java" target-dir="src/plugin/google/maps"/>
<source-file src="src/android/plugin/google/maps/PluginDirectionsService.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"/>
Expand Down Expand Up @@ -282,6 +301,9 @@
<resource-file src="src/android/res/values-da/pgm_strings.xml" target="res/values-da/pgm_strings.xml"/>
<!-- localized messages for Vietnamese -->
<resource-file src="src/android/res/values-vi/pgm_strings.xml" target="res/values-vi/pgm_strings.xml"/>

<dependency id="cordova-androidx-build" />

</platform>

<!-- ios -->
Expand Down Expand Up @@ -316,6 +338,12 @@
<feature name="PluginLocationService">
<param name="ios-package" value="PluginLocationService"/>
</feature>
<feature name="PluginElevationService">
<param name="ios-package" value="PluginElevationService"/>
</feature>
<feature name="PluginDirectionsService">
<param name="ios-package" value="PluginDirectionsService"/>
</feature>
<feature name="PluginMap">
<param name="ios-package" value="PluginMap"/>
</feature>
Expand Down Expand Up @@ -356,6 +384,10 @@
<source-file src="src/ios/GoogleMaps/PluginGeocoder.m"/>
<header-file src="src/ios/GoogleMaps/PluginLocationService.h"/>
<source-file src="src/ios/GoogleMaps/PluginLocationService.m"/>
<header-file src="src/ios/GoogleMaps/PluginElevationService.h"/>
<source-file src="src/ios/GoogleMaps/PluginElevationService.m"/>
<header-file src="src/ios/GoogleMaps/PluginDirectionsService.h"/>
<source-file src="src/ios/GoogleMaps/PluginDirectionsService.m"/>
<header-file src="src/ios/GoogleMaps/PluginEnvironment.h"/>
<source-file src="src/ios/GoogleMaps/PluginEnvironment.m"/>
<header-file src="src/ios/GoogleMaps/CordovaGoogleMaps.h"/>
Expand Down Expand Up @@ -516,6 +548,12 @@
<js-module name="PluginLocationService" src="src/browser/PluginLocationService.js">
<runs/>
</js-module>
<js-module name="PluginElevationService" src="src/browser/PluginElevationService.js">
<runs/>
</js-module>
<js-module name="PluginDirectionsService" src="src/browser/PluginDirectionsService.js">
<runs/>
</js-module>
<js-module name="PluginGeocoder" src="src/browser/PluginGeocoder.js">
<runs/>
</js-module>
Expand Down
146 changes: 114 additions & 32 deletions src/android/frameworks/pgm-custom.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
def getConvertListe(useAndroidX) {
def list = [
["com.google.android.gms.maps.model", "com.google.android.libraries.maps.model"],
["com.google.android.gms.maps", "com.google.android.libraries.maps"]
]

if (!useAndroidX) {
def tmp;
def listN = list.size()
for (int i = 0; i < listN; i++) {
tmp = list[i][0]
list[i][0] = list[i][1]
list[i][1] = tmp
}
}
return list
}


def searchFileInParents(target) {
def searchPath = target
for (int i = 0; i < 8; i++) {
Expand All @@ -12,6 +31,59 @@ def searchFileInParents(target) {
return null;
}

def replacePackages(file, cvtList, useAndroidX) {
def filePath = file.toPath()
def lines = java.nio.file.Files.readAllLines(filePath)
def linesN = lines.size()
def listN = cvtList.size()
def anyChanges = false
for (int i = 0; i < linesN; i++) {
def line = lines.get(i)
def needReplace = false;
if (useAndroidX && line.contains('android.')) {
needReplace = true
} else if (!useAndroidX && line.contains('android')) {
needReplace = true
}
if (needReplace) {
for (int j = 0; j < listN; j++) {
if (line.contains(cvtList[j][0])) {
anyChanges = true
line = line.replaceAll(cvtList[j][0], cvtList[j][1])
}
}
lines.set(i, line)
}
}

if (anyChanges) {
println(" [changed] " + file)
def fileWriter = new FileWriter(file)
def output = new BufferedWriter(fileWriter)
for (int i = 0; i < linesN; i++) {
output.writeLine(lines.get(i))
}
output.flush()
output.close()
fileWriter.close()
}

}
def replaceFiles(matchingPattern, cvtList, useAndroidX) {

PatternFilterable patternSet = new PatternSet();
patternSet.include(matchingPattern);

def matchedFile = project.files(project.getProjectDir().getParentFile().toPath()).getAsFileTree().matching(patternSet)
matchedFile.each { file ->
if (!java.nio.file.Files.isReadable(file.toPath())) {
return
}

replacePackages(file, cvtList, useAndroidX)
}
}

android {
// #1. Find (project)/config.xml file,
// because ionic capacitor does not copy <preference> nodes
Expand All @@ -35,13 +107,13 @@ android {
if (widget.preference.size() == 0) {
throw new GradleException("Please add '<preference name=\"GOOGLE_MAPS_ANDROID_API_KEY\" />' to the config.xml file.")
}
println("preference = " + widget.preference.size())
Properties props = new Properties()
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", "");

props.setProperty("GOOGLE_MAPS_PLAY_SERVICES_LOCATION_VERSION", "16.0.0");
props.setProperty("GOOGLE_MAPS_ANDROID_SUPPORT_V4_VERSION", "27.1.1");
props.setProperty("GOOGLE_MAPS_PLAY_SERVICES_VERSION", "16.1.0");


widget.preference.each { pref ->
def name = pref.attributes().name
Expand All @@ -51,49 +123,59 @@ android {
isKeyFound = 1
props.setProperty(name, value)
}
if (name == "GOOGLE_MAPS_PLAY_SERVICES_VERSION" ||
name == "ANDROID_SUPPORT_V4_VERSION") {
if (name == "GOOGLE_MAPS_PLAY_SERVICES_LOCATION_VERSION"||
name == "GOOGLE_MAPS_PLAY_SERVICES_VERSION" ||
name == "GOOGLE_MAPS_ANDROID_SUPPORT_V4_VERSION") {
props.setProperty(name, value)
}
if (name == "GOOGLE_MAPS_ANDROID_SDK") {
useBetaSdk = 1
props.setProperty("GOOGLE_MAPS_ANDROID_SDK", value)
}
}


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}/libs/")
if (!libsDir.exists()) {
libsDir.mkdirs()
def hasUseAndroidX = project.ext.has('android.useAndroidX')
def hasEnableJetifier = project.ext.has('android.enableJetifier')
def useAndroidX = hasUseAndroidX && hasEnableJetifier &&
'true' == project.ext.get('android.useAndroidX') &&
'true' == project.ext.get('android.enableJetifier')

//-----------------------------------------------
// Replace the source code of this plugin
//-----------------------------------------------
def cvtList = getConvertListe(useAndroidX)

replaceFiles("**/plugin/google/maps/*.java", cvtList, useAndroidX)

if (useAndroidX) {
//----------
// maps SDK
//----------

dependencies {
implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
implementation 'com.android.support:multidex:1.0.3'
}

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 }}
defaultConfig {
multiDexEnabled true
}

} else {
def PLAY_SERVICES_VERSION = props.getProperty("GOOGLE_MAPS_PLAY_SERVICES_VERSION")
def PLAY_SERVICES_LOCATION_VERSION = props.getProperty("GOOGLE_MAPS_PLAY_SERVICES_LOCATION_VERSION")
def ANDROID_SUPPORT_V4_VERSION = props.getProperty("GOOGLE_MAPS_ANDROID_SUPPORT_V4_VERSION")
println("---->GOOGLE_MAPS_PLAY_SERVICES_VERSION = ${PLAY_SERVICES_VERSION}")
println("---->GOOGLE_MAPS_PLAY_SERVICES_LOCATION_VERSION = ${PLAY_SERVICES_LOCATION_VERSION}")
println("---->GOOGLE_MAPS_ANDROID_SUPPORT_V4_VERSION = ${ANDROID_SUPPORT_V4_VERSION}")
dependencies {
implementation name: mapsSDK, ext:'aar'
implementation "com.google.android.gms:play-services-maps:${PLAY_SERVICES_VERSION}"
implementation "com.google.android.gms:play-services-location:${PLAY_SERVICES_LOCATION_VERSION}"
implementation "com.android.support:support-core-utils:${ANDROID_SUPPORT_V4_VERSION}"
}
}

def PLAY_SERVICES_VERSION = props.get("GOOGLE_MAPS_PLAY_SERVICES_VERSION")
def ANDROID_SUPPORT_V4_VERSION = props.get("ANDROID_SUPPORT_V4_VERSION")
println("---->PLAY_SERVICES_VERSION = ${PLAY_SERVICES_VERSION}")
println("---->ANDROID_SUPPORT_V4_VERSION = ${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 {
Expand Down
2 changes: 1 addition & 1 deletion src/android/frameworks/tbxml-android.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
}

android {
compileSdkVersion 26
compileSdkVersion 28

packagingOptions {
exclude 'README'
Expand Down
Loading