Skip to content

Commit

Permalink
Merge branch 'main' into addLocationEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljosua1 authored Oct 8, 2024
2 parents 8990daf + 5a3daa2 commit a47403d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,24 @@ public void onError(@NonNull String message) {
});
break;
}
case "map#clearAmbientCache":
{
OfflineManager fileSource = OfflineManager.Companion.getInstance(context);

fileSource.clearAmbientCache(
new OfflineManager.FileSourceCallback() {
@Override
public void onSuccess() {
result.success(null);
}

@Override
public void onError(@NonNull String message) {
result.error("MAPBOX CACHE ERROR", message, null);
}
});
break;
}
case "source#addGeoJson":
{
final String sourceId = call.argument("sourceId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ class MapLibreMapController: NSObject, FlutterPlatformView, MLNMapViewDelegate,
result(nil)
}
}
case "map#clearAmbientCache":
MLNOfflineStorage.shared.clearAmbientCache {
error in
if let error = error {
result(error)
} else {
result(nil)
}
}
case "map#updateMyLocationTrackingMode":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
if let myLocationTrackingMode = arguments["mode"] as? UInt,
Expand Down
4 changes: 4 additions & 0 deletions maplibre_gl/lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,10 @@ class MapLibreMapController extends ChangeNotifier {
return _maplibrePlatform.invalidateAmbientCache();
}

Future clearAmbientCache() async {
return _maplibrePlatform.clearAmbientCache();
}

/// Get last my location
///
/// Return last latlng, nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ abstract class MapLibrePlatform {
Future<List> querySourceFeatures(
String sourceId, String? sourceLayerId, List<Object>? filter);
Future invalidateAmbientCache();
Future clearAmbientCache();
Future<LatLng?> requestMyLocationLatLng();

Future<LatLngBounds> getVisibleRegion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ class MapLibreMethodChannel extends MapLibrePlatform {
}
}

@override
Future clearAmbientCache() async {
try {
await _channel.invokeMethod('map#clearAmbientCache');
return null;
} on PlatformException catch (e) {
return Future.error(e);
}
}

@override
Future<LatLng> requestMyLocationLatLng() async {
try {
Expand Down
5 changes: 5 additions & 0 deletions maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ class MapLibreMapController extends MapLibrePlatform
print('Offline storage not available in web');
}

@override
Future clearAmbientCache() async {
print('Offline storage not available in web');
}

@override
Future<LatLng?> requestMyLocationLatLng() async {
return _myLastLocation;
Expand Down

0 comments on commit a47403d

Please sign in to comment.