Experimental API to toggle tile cache in map view (#2590)

This commit is contained in:
Alex Cristici
2024-07-16 01:31:11 +03:00
committed by GitHub
parent 9119afc5a3
commit 1ae14a55d0
21 changed files with 93 additions and 4 deletions

View File

@@ -2504,4 +2504,18 @@ public final class MapLibreMap {
listener.onDeveloperAnimationStarted();
}
}
//
// Tile cache
//
/**
* Indicating whether the map may cache tiles for different zoom levels or not.
*
* @param enabled true causes the map view to consume more memory and have a smoother user
* experience when zoom in/out. The default value of this property is `true`.
*/
public void experimental_setTileCacheEnabled(boolean enabled) {
nativeMapView.setTileCacheEnabled(enabled);
}
}

View File

@@ -33,6 +33,8 @@ interface NativeMap {
void resizeView(int width, int height);
void setTileCacheEnabled(boolean enabled);
void onLowMemory();
void destroy();

View File

@@ -619,6 +619,14 @@ final class NativeMapView implements NativeMap {
nativeSetVisibleCoordinateBounds(coordinates, padding, direction, duration);
}
@Override
public void setTileCacheEnabled(boolean enabled) {
if (checkState("setTileCacheEnabled")) {
return;
}
nativeSetTileCacheEnabled(enabled);
}
@Override
public void onLowMemory() {
if (checkState("onLowMemory")) {
@@ -1332,6 +1340,9 @@ final class NativeMapView implements NativeMap {
private native void nativeSetVisibleCoordinateBounds(LatLng[] coordinates, RectF padding,
double direction, long duration);
@Keep
private native void nativeSetTileCacheEnabled(boolean enabled);
@Keep
private native void nativeOnLowMemory();