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

New renderer #1

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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