Skip to content

Commit

Permalink
Merge pull request #1 from shajz/ref.new.renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
shajz authored Jan 5, 2024
2 parents 36bd759 + 98acd4a commit e001568
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) **GOOGLE_MAPS_PLAY_SERVICES_VERSION = (16.0.1)**<br>
- ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/icon-android.png) **GOOGLE_MAPS_PLAY_SERVICES_VERSION = (18.+)**<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).
Expand Down
2 changes: 1 addition & 1 deletion src/android/frameworks/pgm-custom.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {
Properties props = new Properties()
def isKeyFound = 0
def useBetaSdk = 0
props.setProperty("GOOGLE_MAPS_PLAY_SERVICES_VERSION", "16.0.0");
props.setProperty("GOOGLE_MAPS_PLAY_SERVICES_VERSION", "18.+");
props.setProperty("ANDROID_SUPPORT_V4_VERSION", "27.1.1");
props.setProperty("GOOGLE_MAPS_ANDROID_SDK", "");

Expand Down
24 changes: 20 additions & 4 deletions src/android/plugin/google/maps/CordovaGoogleMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;

import androidx.annotation.NonNull;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.MapsInitializer.Renderer;
import com.google.android.gms.maps.OnMapsSdkInitializedCallback;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
Expand All @@ -45,7 +49,7 @@
import java.util.Set;

@SuppressWarnings("deprecation")
public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver.OnScrollChangedListener{
public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver.OnScrollChangedListener, OnMapsSdkInitializedCallback {
private final String TAG = "GoogleMapsPlugin";
private Activity activity;
public ViewGroup root;
Expand All @@ -69,6 +73,8 @@ public void initialize(final CordovaInterface cordova, final CordovaWebView webV

pluginManager = webView.getPluginManager();

CordovaGoogleMaps that = this;

cordova.getActivity().runOnUiThread(new Runnable() {
@SuppressLint("NewApi")
public void run() {
Expand Down Expand Up @@ -202,17 +208,27 @@ public void onClick(DialogInterface dialog,int id) {
//------------------------------
if (!initialized) {
try {
MapsInitializer.initialize(cordova.getActivity());
initialized = true;
MapsInitializer.initialize(cordova.getActivity(), Renderer.LATEST, that);
} catch (Exception e) {
e.printStackTrace();
}
}

}
});
}


@Override
public void onMapsSdkInitialized(@NonNull Renderer renderer) {
initialized = true;
switch (renderer) {
case LATEST:
Log.d(TAG, "The latest version of the renderer is used");
break;
case LEGACY:
Log.d(TAG, "The legacy version of the renderer is used");
break;
}
}

@Override
Expand Down

0 comments on commit e001568

Please sign in to comment.