@maplibre/maplibre-react-native 10.0.0-beta.16 → 10.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +29 -6
- package/android/gradle.properties +11 -6
- package/android/src/main/java/org/maplibre/reactnative/location/LocationManager.java +7 -11
- package/android/src/main/java/org/maplibre/reactnative/location/engine/DefaultLocationEngineProvider.java +18 -0
- package/android/src/main/java/org/maplibre/reactnative/location/engine/LocationEngineProvidable.java +9 -0
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNModule.java +24 -2
- package/android/src/main/location-engine-default/org/maplibre/reactnative/location/engine/LocationEngineProvider.java +12 -0
- package/android/src/main/location-engine-google/org/maplibre/reactnative/location/engine/GoogleLocationEngineImpl.java +151 -0
- package/android/src/main/location-engine-google/org/maplibre/reactnative/location/engine/GoogleLocationEngineProvider.java +24 -0
- package/android/src/main/location-engine-google/org/maplibre/reactnative/location/engine/LocationEngineProvider.java +12 -0
- package/ios/MLRN/MLRNModule.m +8 -0
- package/lib/commonjs/MLRNModule.js.map +1 -1
- package/lib/module/MLRNModule.js.map +1 -1
- package/lib/typescript/commonjs/src/MLRNModule.d.ts.map +1 -1
- package/lib/typescript/module/src/MLRNModule.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MLRNModule.ts +8 -0
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
buildscript {
|
|
2
2
|
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["org.maplibre.reactnative.kotlinVersion"]
|
|
4
4
|
|
|
5
5
|
repositories {
|
|
6
6
|
google()
|
|
@@ -32,11 +32,15 @@ apply plugin: "kotlin-android"
|
|
|
32
32
|
// }
|
|
33
33
|
|
|
34
34
|
def getExtOrDefault(name) {
|
|
35
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["
|
|
35
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["org.maplibre.reactnative." + name]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
def getConfigurableExtOrDefault(name) {
|
|
39
|
+
return rootProject.ext.has("org.maplibre.reactnative." + name) ? rootProject.ext.get("org.maplibre.reactnative." + name) : project.properties["org.maplibre.reactnative." + name]
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
def getExtOrIntegerDefault(name) {
|
|
39
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["
|
|
43
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["org.maplibre.reactnative." + name]).toInteger()
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
def supportsNamespace() {
|
|
@@ -68,6 +72,20 @@ android {
|
|
|
68
72
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
sourceSets {
|
|
76
|
+
main {
|
|
77
|
+
java.srcDirs = ['src/main/java']
|
|
78
|
+
|
|
79
|
+
if (getConfigurableExtOrDefault("locationEngine") == "default") {
|
|
80
|
+
java.srcDirs += 'src/main/location-engine-default'
|
|
81
|
+
} else if (getConfigurableExtOrDefault("locationEngine") == "google") {
|
|
82
|
+
java.srcDirs += 'src/main/location-engine-google'
|
|
83
|
+
} else {
|
|
84
|
+
throw new GradleException("org.maplibre.reactnative.locationEngine.locationEngine should be one of [\"default\", \"google\"]`. \"${getConfigurableExtOrDefault("locationEngine")}\" was provided.")
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
71
89
|
buildTypes {
|
|
72
90
|
release {
|
|
73
91
|
minifyEnabled false
|
|
@@ -106,11 +124,16 @@ dependencies {
|
|
|
106
124
|
implementation "androidx.vectordrawable:vectordrawable:1.1.0"
|
|
107
125
|
implementation "androidx.annotation:annotation:1.7.0"
|
|
108
126
|
implementation "androidx.appcompat:appcompat:1.6.1"
|
|
109
|
-
implementation "com.squareup.okhttp3:okhttp:${
|
|
110
|
-
implementation "com.squareup.okhttp3:okhttp-urlconnection:${
|
|
127
|
+
implementation "com.squareup.okhttp3:okhttp:${getConfigurableExtOrDefault('okhttpVersion')}"
|
|
128
|
+
implementation "com.squareup.okhttp3:okhttp-urlconnection:${getConfigurableExtOrDefault('okhttpVersion')}"
|
|
111
129
|
|
|
112
|
-
// MapLibre
|
|
130
|
+
// MapLibre Plugins
|
|
113
131
|
implementation ("org.maplibre.gl:android-plugin-localization-v9:3.0.1")
|
|
114
132
|
implementation ("org.maplibre.gl:android-plugin-annotation-v9:3.0.1")
|
|
115
133
|
implementation ("org.maplibre.gl:android-plugin-markerview-v9:3.0.1")
|
|
134
|
+
|
|
135
|
+
// Dependencies for Google Location Engine
|
|
136
|
+
if (getConfigurableExtOrDefault("locationEngine") == "google") {
|
|
137
|
+
implementation "com.google.android.gms:play-services-location:21.3.0"
|
|
138
|
+
}
|
|
116
139
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
org.maplibre.reactnative.kotlinVersion=1.7.0
|
|
2
|
+
org.maplibre.reactnative.minSdkVersion=21
|
|
3
|
+
org.maplibre.reactnative.targetSdkVersion=31
|
|
4
|
+
org.maplibre.reactnative.compileSdkVersion=31
|
|
5
|
+
org.maplibre.reactnative.ndkVersion=21.4.7075529
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# MapLibre React Native Customizations
|
|
8
|
+
|
|
9
|
+
org.maplibre.reactnative.okhttpVersion=4.9.0
|
|
10
|
+
|
|
11
|
+
# Available values: default, google
|
|
12
|
+
org.maplibre.reactnative.locationEngine=default
|
|
@@ -7,21 +7,14 @@ import android.util.Log;
|
|
|
7
7
|
|
|
8
8
|
import org.maplibre.android.location.engine.LocationEngine;
|
|
9
9
|
import org.maplibre.android.location.engine.LocationEngineCallback;
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
import com.mapbox.android.core.location.LocationEngineListener;
|
|
13
|
-
import com.mapbox.android.core.location.LocationEnginePriority;
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import org.maplibre.android.location.engine.LocationEngineDefault;
|
|
17
10
|
import org.maplibre.android.location.engine.LocationEngineRequest;
|
|
18
11
|
import org.maplibre.android.location.engine.LocationEngineResult;
|
|
19
12
|
import org.maplibre.android.location.permissions.PermissionsManager;
|
|
13
|
+
import org.maplibre.reactnative.location.engine.LocationEngineProvider;
|
|
20
14
|
|
|
21
15
|
import java.lang.ref.WeakReference;
|
|
22
16
|
import java.util.ArrayList;
|
|
23
17
|
import java.util.List;
|
|
24
|
-
import java.util.Locale;
|
|
25
18
|
|
|
26
19
|
@SuppressWarnings({"MissingPermission"})
|
|
27
20
|
public class LocationManager implements LocationEngineCallback<LocationEngineResult> {
|
|
@@ -58,8 +51,10 @@ public class LocationManager implements LocationEngineCallback<LocationEngineRes
|
|
|
58
51
|
this.buildEngineRequest();
|
|
59
52
|
|
|
60
53
|
}
|
|
54
|
+
|
|
61
55
|
private void buildEngineRequest() {
|
|
62
|
-
locationEngine =
|
|
56
|
+
locationEngine = new LocationEngineProvider().getLocationEngine(context);
|
|
57
|
+
|
|
63
58
|
locationEngineRequest = new LocationEngineRequest.Builder(DEFAULT_INTERVAL_MILLIS)
|
|
64
59
|
.setFastestInterval(DEFAULT_FASTEST_INTERVAL_MILLIS)
|
|
65
60
|
.setPriority(LocationEngineRequest.PRIORITY_HIGH_ACCURACY)
|
|
@@ -78,9 +73,11 @@ public class LocationManager implements LocationEngineCallback<LocationEngineRes
|
|
|
78
73
|
listeners.remove(listener);
|
|
79
74
|
}
|
|
80
75
|
}
|
|
76
|
+
|
|
81
77
|
public void setMinDisplacement(float minDisplacement) {
|
|
82
78
|
mMinDisplacement = minDisplacement;
|
|
83
79
|
}
|
|
80
|
+
|
|
84
81
|
public void enable() {
|
|
85
82
|
if (!PermissionsManager.areLocationPermissionsGranted(context)) {
|
|
86
83
|
return;
|
|
@@ -134,8 +131,7 @@ public class LocationManager implements LocationEngineCallback<LocationEngineRes
|
|
|
134
131
|
|
|
135
132
|
try {
|
|
136
133
|
locationEngine.getLastLocation(callback);
|
|
137
|
-
}
|
|
138
|
-
catch(Exception exception) {
|
|
134
|
+
} catch (Exception exception) {
|
|
139
135
|
Log.w(LOG_TAG, exception);
|
|
140
136
|
callback.onFailure(exception);
|
|
141
137
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import org.maplibre.android.location.engine.LocationEngine;
|
|
7
|
+
import org.maplibre.android.location.engine.LocationEngineDefault;
|
|
8
|
+
|
|
9
|
+
public class DefaultLocationEngineProvider implements LocationEngineProvidable {
|
|
10
|
+
private static final String LOG_TAG = "DefaultLocationEngineProvider";
|
|
11
|
+
|
|
12
|
+
@Override
|
|
13
|
+
public LocationEngine getLocationEngine(Context context) {
|
|
14
|
+
LocationEngine locationEngine = LocationEngineDefault.INSTANCE.getDefaultLocationEngine(context.getApplicationContext());
|
|
15
|
+
Log.d(LOG_TAG, "DefaultLocationEngine will be used.");
|
|
16
|
+
return locationEngine;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -44,6 +44,11 @@ public class MLRNModule extends ReactContextBaseJavaModule {
|
|
|
44
44
|
mReactContext = reactApplicationContext;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
@Override
|
|
48
|
+
public void initialize() {
|
|
49
|
+
initializeMapLibreInstance();
|
|
50
|
+
}
|
|
51
|
+
|
|
47
52
|
@Override
|
|
48
53
|
public String getName() {
|
|
49
54
|
return REACT_CLASS;
|
|
@@ -127,7 +132,11 @@ public class MLRNModule extends ReactContextBaseJavaModule {
|
|
|
127
132
|
.build();
|
|
128
133
|
}
|
|
129
134
|
|
|
130
|
-
|
|
135
|
+
/**
|
|
136
|
+
* @deprecated This will be removed in the next major version.
|
|
137
|
+
* @see https://github.com/maplibre/maplibre-react-native/issues/25#issuecomment-1382382044
|
|
138
|
+
*/
|
|
139
|
+
@Deprecated
|
|
131
140
|
@ReactMethod
|
|
132
141
|
public void setAccessToken(final String accessToken) {
|
|
133
142
|
mReactContext.runOnUiQueueThread(new Runnable() {
|
|
@@ -170,7 +179,11 @@ public class MLRNModule extends ReactContextBaseJavaModule {
|
|
|
170
179
|
});
|
|
171
180
|
}
|
|
172
181
|
|
|
173
|
-
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated This will be removed in the next major version.
|
|
184
|
+
* @see https://github.com/maplibre/maplibre-react-native/issues/25#issuecomment-1382382044
|
|
185
|
+
*/
|
|
186
|
+
@Deprecated
|
|
174
187
|
@ReactMethod
|
|
175
188
|
public void getAccessToken(Promise promise) {
|
|
176
189
|
String token = MapLibre.getApiKey();
|
|
@@ -198,4 +211,13 @@ public class MLRNModule extends ReactContextBaseJavaModule {
|
|
|
198
211
|
dispatcher.setMaxRequestsPerHost(20);
|
|
199
212
|
return dispatcher;
|
|
200
213
|
}
|
|
214
|
+
|
|
215
|
+
private void initializeMapLibreInstance() {
|
|
216
|
+
mReactContext.runOnUiQueueThread(new Runnable() {
|
|
217
|
+
@Override
|
|
218
|
+
public void run() {
|
|
219
|
+
MapLibre.getInstance(getReactApplicationContext());
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
201
223
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import org.maplibre.android.location.engine.LocationEngine;
|
|
6
|
+
|
|
7
|
+
public class LocationEngineProvider implements LocationEngineProvidable {
|
|
8
|
+
@Override
|
|
9
|
+
public LocationEngine getLocationEngine(Context context) {
|
|
10
|
+
return new DefaultLocationEngineProvider().getLocationEngine(context);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint;
|
|
4
|
+
import android.app.PendingIntent;
|
|
5
|
+
import android.content.Context;
|
|
6
|
+
import android.location.Location;
|
|
7
|
+
import android.os.Looper;
|
|
8
|
+
|
|
9
|
+
import androidx.annotation.NonNull;
|
|
10
|
+
import androidx.annotation.Nullable;
|
|
11
|
+
import androidx.annotation.VisibleForTesting;
|
|
12
|
+
|
|
13
|
+
import com.google.android.gms.location.FusedLocationProviderClient;
|
|
14
|
+
import com.google.android.gms.location.LocationCallback;
|
|
15
|
+
import com.google.android.gms.location.LocationRequest;
|
|
16
|
+
import com.google.android.gms.location.LocationResult;
|
|
17
|
+
import com.google.android.gms.location.LocationServices;
|
|
18
|
+
import com.google.android.gms.location.Priority;
|
|
19
|
+
import com.google.android.gms.tasks.OnFailureListener;
|
|
20
|
+
import com.google.android.gms.tasks.OnSuccessListener;
|
|
21
|
+
|
|
22
|
+
import org.maplibre.android.location.engine.LocationEngineCallback;
|
|
23
|
+
import org.maplibre.android.location.engine.LocationEngineImpl;
|
|
24
|
+
import org.maplibre.android.location.engine.LocationEngineRequest;
|
|
25
|
+
import org.maplibre.android.location.engine.LocationEngineResult;
|
|
26
|
+
|
|
27
|
+
import java.util.Collections;
|
|
28
|
+
import java.util.List;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Wraps implementation of Fused Location Provider
|
|
32
|
+
*/
|
|
33
|
+
public class GoogleLocationEngineImpl implements LocationEngineImpl<LocationCallback> {
|
|
34
|
+
private final FusedLocationProviderClient fusedLocationProviderClient;
|
|
35
|
+
|
|
36
|
+
@VisibleForTesting
|
|
37
|
+
GoogleLocationEngineImpl(FusedLocationProviderClient fusedLocationProviderClient) {
|
|
38
|
+
this.fusedLocationProviderClient = fusedLocationProviderClient;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public GoogleLocationEngineImpl(@NonNull Context context) {
|
|
42
|
+
this.fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@NonNull
|
|
46
|
+
@Override
|
|
47
|
+
public LocationCallback createListener(LocationEngineCallback<LocationEngineResult> callback) {
|
|
48
|
+
return new GoogleLocationEngineCallbackTransport(callback);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@SuppressLint("MissingPermission")
|
|
52
|
+
@Override
|
|
53
|
+
public void getLastLocation(@NonNull LocationEngineCallback<LocationEngineResult> callback)
|
|
54
|
+
throws SecurityException {
|
|
55
|
+
GoogleLastLocationEngineCallbackTransport transport =
|
|
56
|
+
new GoogleLastLocationEngineCallbackTransport(callback);
|
|
57
|
+
fusedLocationProviderClient.getLastLocation().addOnSuccessListener(transport).addOnFailureListener(transport);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@SuppressLint("MissingPermission")
|
|
61
|
+
@Override
|
|
62
|
+
public void requestLocationUpdates(@NonNull LocationEngineRequest request,
|
|
63
|
+
@NonNull LocationCallback listener,
|
|
64
|
+
@Nullable Looper looper) throws SecurityException {
|
|
65
|
+
fusedLocationProviderClient.requestLocationUpdates(toGMSLocationRequest(request), listener, looper);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@SuppressLint("MissingPermission")
|
|
69
|
+
@Override
|
|
70
|
+
public void requestLocationUpdates(@NonNull LocationEngineRequest request,
|
|
71
|
+
@NonNull PendingIntent pendingIntent) throws SecurityException {
|
|
72
|
+
fusedLocationProviderClient.requestLocationUpdates(toGMSLocationRequest(request), pendingIntent);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Override
|
|
76
|
+
public void removeLocationUpdates(@NonNull LocationCallback listener) {
|
|
77
|
+
if (listener != null) {
|
|
78
|
+
fusedLocationProviderClient.removeLocationUpdates(listener);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Override
|
|
83
|
+
public void removeLocationUpdates(PendingIntent pendingIntent) {
|
|
84
|
+
if (pendingIntent != null) {
|
|
85
|
+
fusedLocationProviderClient.removeLocationUpdates(pendingIntent);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private static LocationRequest toGMSLocationRequest(LocationEngineRequest request) {
|
|
90
|
+
LocationRequest.Builder builder = new LocationRequest.Builder(request.getInterval());
|
|
91
|
+
builder.setMinUpdateIntervalMillis(request.getFastestInterval());
|
|
92
|
+
builder.setMinUpdateDistanceMeters(request.getDisplacement());
|
|
93
|
+
builder.setMaxUpdateDelayMillis(request.getMaxWaitTime());
|
|
94
|
+
builder.setPriority(toGMSLocationPriority(request.getPriority()));
|
|
95
|
+
return builder.build();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private static int toGMSLocationPriority(int enginePriority) {
|
|
99
|
+
switch (enginePriority) {
|
|
100
|
+
case LocationEngineRequest.PRIORITY_HIGH_ACCURACY:
|
|
101
|
+
return Priority.PRIORITY_HIGH_ACCURACY;
|
|
102
|
+
case LocationEngineRequest.PRIORITY_BALANCED_POWER_ACCURACY:
|
|
103
|
+
return Priority.PRIORITY_BALANCED_POWER_ACCURACY;
|
|
104
|
+
case LocationEngineRequest.PRIORITY_LOW_POWER:
|
|
105
|
+
return Priority.PRIORITY_LOW_POWER;
|
|
106
|
+
case LocationEngineRequest.PRIORITY_NO_POWER:
|
|
107
|
+
default:
|
|
108
|
+
return Priority.PRIORITY_PASSIVE;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private static final class GoogleLocationEngineCallbackTransport extends LocationCallback {
|
|
113
|
+
private final LocationEngineCallback<LocationEngineResult> callback;
|
|
114
|
+
|
|
115
|
+
GoogleLocationEngineCallbackTransport(LocationEngineCallback<LocationEngineResult> callback) {
|
|
116
|
+
this.callback = callback;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@Override
|
|
120
|
+
public void onLocationResult(LocationResult locationResult) {
|
|
121
|
+
super.onLocationResult(locationResult);
|
|
122
|
+
List<Location> locations = locationResult.getLocations();
|
|
123
|
+
if (!locations.isEmpty()) {
|
|
124
|
+
callback.onSuccess(LocationEngineResult.create(locations));
|
|
125
|
+
} else {
|
|
126
|
+
callback.onFailure(new Exception("Unavailable location"));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@VisibleForTesting
|
|
132
|
+
static final class GoogleLastLocationEngineCallbackTransport
|
|
133
|
+
implements OnSuccessListener<Location>, OnFailureListener {
|
|
134
|
+
private final LocationEngineCallback<LocationEngineResult> callback;
|
|
135
|
+
|
|
136
|
+
GoogleLastLocationEngineCallbackTransport(LocationEngineCallback<LocationEngineResult> callback) {
|
|
137
|
+
this.callback = callback;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Override
|
|
141
|
+
public void onSuccess(Location location) {
|
|
142
|
+
callback.onSuccess(location != null ? LocationEngineResult.create(location) :
|
|
143
|
+
LocationEngineResult.create(Collections.<Location>emptyList()));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@Override
|
|
147
|
+
public void onFailure(@NonNull Exception e) {
|
|
148
|
+
callback.onFailure(e);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import com.google.android.gms.common.ConnectionResult;
|
|
7
|
+
import com.google.android.gms.common.GoogleApiAvailability;
|
|
8
|
+
|
|
9
|
+
import org.maplibre.android.location.engine.LocationEngine;
|
|
10
|
+
import org.maplibre.android.location.engine.LocationEngineProxy;
|
|
11
|
+
|
|
12
|
+
public class GoogleLocationEngineProvider implements LocationEngineProvidable {
|
|
13
|
+
private static final String LOG_TAG = "GoogleLocationEngineProvider";
|
|
14
|
+
|
|
15
|
+
public LocationEngine getLocationEngine(Context context) {
|
|
16
|
+
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS) {
|
|
17
|
+
LocationEngine locationEngine = new LocationEngineProxy<>(new GoogleLocationEngineImpl(context.getApplicationContext()));
|
|
18
|
+
Log.d(LOG_TAG, "GoogleLocationEngine will be used.");
|
|
19
|
+
return locationEngine;
|
|
20
|
+
} else {
|
|
21
|
+
return new DefaultLocationEngineProvider().getLocationEngine(context);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package org.maplibre.reactnative.location.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import org.maplibre.android.location.engine.LocationEngine;
|
|
6
|
+
|
|
7
|
+
public class LocationEngineProvider implements LocationEngineProvidable {
|
|
8
|
+
@Override
|
|
9
|
+
public LocationEngine getLocationEngine(Context context) {
|
|
10
|
+
return new GoogleLocationEngineProvider().getLocationEngine(context);
|
|
11
|
+
}
|
|
12
|
+
}
|
package/ios/MLRN/MLRNModule.m
CHANGED
|
@@ -90,6 +90,10 @@ RCT_EXPORT_MODULE();
|
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated This will be removed in the next major version.
|
|
95
|
+
* @see https://github.com/maplibre/maplibre-react-native/issues/25#issuecomment-1382382044
|
|
96
|
+
*/
|
|
93
97
|
RCT_EXPORT_METHOD(setAccessToken:(NSString *)accessToken)
|
|
94
98
|
{
|
|
95
99
|
if (accessToken.length > 0) {
|
|
@@ -107,6 +111,10 @@ RCT_EXPORT_METHOD(removeCustomHeader:(NSString *)headerName)
|
|
|
107
111
|
[MLRNCustomHeaders.sharedInstance removeHeader:headerName];
|
|
108
112
|
}
|
|
109
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @deprecated This will be removed in the next major version.
|
|
116
|
+
* @see https://github.com/maplibre/maplibre-react-native/issues/25#issuecomment-1382382044
|
|
117
|
+
*/
|
|
110
118
|
RCT_EXPORT_METHOD(getAccessToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
111
119
|
{
|
|
112
120
|
NSString* accessToken = MLNSettings.apiKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","MLRNModule","Object","create","NativeModules","CameraModes","OfflinePackDownloadState","StyleSource","StyleURL","setAccessToken","getAccessToken","addCustomHeader","removeCustomHeader","setConnected","exports"],"sourceRoot":"../../src","sources":["MLRNModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","MLRNModule","Object","create","NativeModules","CameraModes","OfflinePackDownloadState","StyleSource","StyleURL","setAccessToken","getAccessToken","addCustomHeader","removeCustomHeader","setConnected","exports"],"sourceRoot":"../../src","sources":["MLRNModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AA4CA,MAAMC,UAAuB,GAAGC,MAAM,CAACC,MAAM,CAACC,0BAAa,CAACH,UAAU,CAAC;AAEhE,MAAM;EACXI,WAAW;EACXC,wBAAwB;EACxBC,WAAW;EACXC,QAAQ;EAERC,cAAc;EACdC,cAAc;EAEdC,eAAe;EACfC,kBAAkB;EAElBC;AACF,CAAC,GAAGZ,UAAU;AAACa,OAAA,CAAAD,YAAA,GAAAA,YAAA;AAAAC,OAAA,CAAAF,kBAAA,GAAAA,kBAAA;AAAAE,OAAA,CAAAH,eAAA,GAAAA,eAAA;AAAAG,OAAA,CAAAJ,cAAA,GAAAA,cAAA;AAAAI,OAAA,CAAAL,cAAA,GAAAA,cAAA;AAAAK,OAAA,CAAAN,QAAA,GAAAA,QAAA;AAAAM,OAAA,CAAAP,WAAA,GAAAA,WAAA;AAAAO,OAAA,CAAAR,wBAAA,GAAAA,wBAAA;AAAAQ,OAAA,CAAAT,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","MLRNModule","Object","create","CameraModes","OfflinePackDownloadState","StyleSource","StyleURL","setAccessToken","getAccessToken","addCustomHeader","removeCustomHeader","setConnected"],"sourceRoot":"../../src","sources":["MLRNModule.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["NativeModules","MLRNModule","Object","create","CameraModes","OfflinePackDownloadState","StyleSource","StyleURL","setAccessToken","getAccessToken","addCustomHeader","removeCustomHeader","setConnected"],"sourceRoot":"../../src","sources":["MLRNModule.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,cAAc;AA4C5C,MAAMC,UAAuB,GAAGC,MAAM,CAACC,MAAM,CAACH,aAAa,CAACC,UAAU,CAAC;AAEvE,OAAO,MAAM;EACXG,WAAW;EACXC,wBAAwB;EACxBC,WAAW;EACXC,QAAQ;EAERC,cAAc;EACdC,cAAc;EAEdC,eAAe;EACfC,kBAAkB;EAElBC;AACF,CAAC,GAAGX,UAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLRNModule.d.ts","sourceRoot":"","sources":["../../../../src/MLRNModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"MLRNModule.d.ts","sourceRoot":"","sources":["../../../../src/MLRNModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA4ChD,eAAO,MACL,WAAW;YAzCD,UAAU,CAAC,MAAM;UACnB,UAAU,CAAC,IAAI;YACb,UAAU,CAAC,MAAM;UACnB,UAAU,CAAC,IAAI;GAuCvB,wBAAwB;cAnCZ,MAAM,GAAG,MAAM;YACjB,MAAM,GAAG,MAAM;cACb,MAAM,GAAG,MAAM;cACf,MAAM,GAAG,MAAM;GAiC3B,WAAW;qBA7BQ,MAAM;GA8BzB,QAAQ;aA1BG,MAAM;GA4BjB,cAAc,gBArBc,MAAM,GAAG,IAAI,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAsBlE,cAAc,QAjBI,OAAO,CAAC,MAAM,CAAC,EAmBjC,eAAe,eAjBa,MAAM,eAAe,MAAM,KAAG,IAAI,EAkB9D,kBAAkB,eAjBa,MAAM,KAAG,IAAI,EAmB5C,YAAY,cAjBY,OAAO,KAAG,IAkBtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLRNModule.d.ts","sourceRoot":"","sources":["../../../../src/MLRNModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"MLRNModule.d.ts","sourceRoot":"","sources":["../../../../src/MLRNModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA4ChD,eAAO,MACL,WAAW;YAzCD,UAAU,CAAC,MAAM;UACnB,UAAU,CAAC,IAAI;YACb,UAAU,CAAC,MAAM;UACnB,UAAU,CAAC,IAAI;GAuCvB,wBAAwB;cAnCZ,MAAM,GAAG,MAAM;YACjB,MAAM,GAAG,MAAM;cACb,MAAM,GAAG,MAAM;cACf,MAAM,GAAG,MAAM;GAiC3B,WAAW;qBA7BQ,MAAM;GA8BzB,QAAQ;aA1BG,MAAM;GA4BjB,cAAc,gBArBc,MAAM,GAAG,IAAI,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAsBlE,cAAc,QAjBI,OAAO,CAAC,MAAM,CAAC,EAmBjC,eAAe,eAjBa,MAAM,eAAe,MAAM,KAAG,IAAI,EAkB9D,kBAAkB,eAjBa,MAAM,KAAG,IAAI,EAmB5C,YAAY,cAjBY,OAAO,KAAG,IAkBtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maplibre/maplibre-react-native",
|
|
3
3
|
"description": "React Native library for creating maps with MapLibre Native for Android & iOS",
|
|
4
|
-
"version": "10.0.0-beta.
|
|
4
|
+
"version": "10.0.0-beta.18",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": true
|
package/src/MLRNModule.ts
CHANGED
|
@@ -25,7 +25,15 @@ interface IMLRNModule {
|
|
|
25
25
|
Default: string;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated This will be removed in the next major version.
|
|
30
|
+
* @see https://github.com/maplibre/maplibre-react-native/issues/25#issuecomment-1382382044
|
|
31
|
+
*/
|
|
28
32
|
setAccessToken(accessToken: string | null): Promise<string | null>;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated This will be removed in the next major version.
|
|
35
|
+
* @see https://github.com/maplibre/maplibre-react-native/issues/25#issuecomment-1382382044
|
|
36
|
+
*/
|
|
29
37
|
getAccessToken(): Promise<string>;
|
|
30
38
|
|
|
31
39
|
addCustomHeader(headerName: string, headerValue: string): void;
|