maps
maps copied to clipboard
[Bug]: offlineManager.resetDatabase not clearing pack list
Mapbox Implementation
Mapbox
Mapbox Version
default
Platform
iOS, Android
@rnmapbox/maps
version
10.0.15
Standalone component to reproduce
import { offlineManager } from '@rnmapbox/maps'
import React, { useEffect } from 'react';
function resetDBbug() {
useEffect(() => {
const resetDB = async () => {
await offlineManager.resetDatabase();
const packs = (await offlineManager.getPacks());
}
resetDB();
}, [])
}
Observed behavior and steps to reproduce
When calling await offlineManager.resetDatabase()
and then getting again the list of offline packs, the list remains the same.
This is true after having awated the response from the async resetDatabase
and is true even if we wait for several seconds before calling offlineManager.getPacks()
.
Calling await pack.status()
on any of these packs though will result in "Does not exist"
exception.
Expected behavior
The result of await offlineManager.getPacks()
should be an empty list, as the offline tile packs should have been cleared.
Notes / preliminary analysis
Restarting the app completely and calling getPacks()
will return correctly an empty list.
Additional links and references
No response
Have you try close the app and open it again? Do the list have been gone? I also stuck on same issue and manage to fix it!
I am facing the same problem not able to delete offline maps and also not able to reset the database both functions are not working. It would be great if you guys can help.
I am facing the same problem not able to delete offline maps and also not able to reset the database both functions are not working. It would be great if you guys can help.
@vishaldybot Have you tried to close the app after resetting the database or deleting the offline maps?
@thdailong Yes, I have done everything and if possible can you please help with this?? as I am in the end of the project and now facing this issue. If you want I can share you how can you a standalone file with you so that you can try the same.
@vishaldybot It would be great if you could provide more information about the issue you are facing. I have facing a similar issue https://github.com/rnmapbox/maps/issues/3265 and managed to fix this bug.
@thdailong,` I was following samething but I was creating multiple offline packs. After that i want clear the all downloaded offlinemaps so i am calling offlineManager.resetDatabase() API, after calling api downloaded offline map names was not showing in console but in the app memory size (MB) not clearing and app memory size Increasing while downloading offline map everytime.
import geoViewport from '@mapbox/geo-viewport';
import Mapbox, {Camera,MapView,offlineManager,StyleURL,} from '@rnmapbox/maps;
import { Button, Dimensions, TextInput ,StyleSheet} from 'react-native';
const CENTER_COORD: [number, number] = [-73.970895, 40.723279];
const MAPBOX_VECTOR_TILE_SIZE = 512;
const STYLE_URL = Mapbox.StyleURL.SatelliteStreet;`
const Offline_Map = () => {
const [packName, setPackName] = useState('pack-1');
const [showEditTitle, setShowEditTitle] = useState(false);
return (
<>
<Button
title="Get all packs"
onPress={async () => {
const packs = await offlineManager.getPacks();
console.log('=> packs:', packs);
packs.forEach((pack) => {
console.log(
'pack:',
pack,
'name:',
pack.name,
'bounds:',
pack?.bounds,
'metadata',
pack?.metadata,
);
});
}}
/>
<Button
title="Remove packs"
onPress={async () => {
const result = await offlineManager.resetDatabase();
console.log('Reset DB done:', result);
}}
/>
<Button
title="Create Pack"
onPress={() => {
const { width, height } = Dimensions.get('window');
const bounds: [number, number, number, number] = geoViewport.bounds(
CENTER_COORD,
12,
[width, height],
MAPBOX_VECTOR_TILE_SIZE,
);
const options = {
name: packName,
styleURL: STYLE_URL,
bounds: [
[bounds[0], bounds[1]],
[bounds[2], bounds[3]],
] as [[number, number], [number, number]],
minZoom: 10,
maxZoom: 20,
metadata: {
whatIsThat: 'foo',
},
};
offlineManager.createPack(options, (region, status) =>
console.log('=> progress callback region:', 'status: ', status),
);
}}
/>
</>
);
}
export default Offline_Map;
#3265
In console after clicking the create pack
LOG => progress callback region: status: {"completedResourceCount": 26, "completedResourceSize": 291159087, "erroredResourceCount": 0, "loadedResourceCount": 26, "loadedResourceSize": 291159087, "name": "pack-1", "percentage": 96.29629629629629, "requiredResourceCount": 27, "state": "active"} LOG => progress callback region: status: {"completedResourceCount": 27, "completedResourceSize": 320010097, "erroredResourceCount": 0, "loadedResourceCount": 27, "loadedResourceSize": 320010097, "name": "pack-1", "percentage": 100, "requiredResourceCount": 27, "state": "complete"}
while clicking the get all packs
0, "name": "pack-1", "percentage": 100, "requiredResourceCount": 27, "state": "complete"} LOG => packs: [{"_metadata": {"_rnmapbox": [Object], "name": "pack-1", "whatIsThat": "foo"}, "pack": {"bounds": [Array], "completedResourceCount": 27, "completedResourceSize": 320010097, "expires": "Sat Apr 20 13:07:11 GMT+05:30 2024", "metadata": "{\"whatIsThat\":\"foo\",\"name\":\"pack-1\",\"_rnmapbox\":{\"bounds\":{\"coordinates\":[[[-74.0258789,40.6598059],[-73.9160156,40.6598059],[-73.9160156,40.7867804],[-74.0258789,40.7867804],[-74.0258789,40.6598059]]],\"type\":\"Polygon\"},\"styleURI\":\"mapbox:\\/\\/styles\\/mapbox\\/satellite-streets-v11\",\"zoomRange\":[10,20]}}", "percentage": 100, "requiredResourceCount": 27, "state": "complete"}}] LOG pack: {"_metadata": {"_rnmapbox": {"bounds": [Object], "styleURI": "mapbox://styles/mapbox/satellite-streets-v11", "zoomRange": [Array]}, "name": "pack-1", "whatIsThat": "foo"}, "pack": {"bounds": [-73.916015625, 40.78678041401646, -74.02587890625, 40.65980593837852], "completedResourceCount": 27, "completedResourceSize": 320010097, "expires": "Sat Apr 20 13:07:11 GMT+05:30 2024", "metadata": "{\"whatIsThat\":\"foo\",\"name\":\"pack-1\",\"_rnmapbox\":{\"bounds\":{\"coordinates\":[[[-74.0258789,40.6598059],[-73.9160156,40.6598059],[-73.9160156,40.7867804],[-74.0258789,40.7867804],[-74.0258789,40.6598059]]],\"type\":\"Polygon\"},\"styleURI\":\"mapbox:\\/\\/styles\\/mapbox\\/satellite-streets-v11\",\"zoomRange\":[10,20]}}", "percentage": 100, "requiredResourceCount": 27, "state": "complete"}} name: pack-1 bounds: [-73.916015625, 40.78678041401646, -74.02587890625, 40.65980593837852] metadata {"_rnmapbox": {"bounds": {"coordinates": [Array], "type": "Polygon"}, "styleURI": "mapbox://styles/mapbox/satellite-streets-v11", "zoomRange": [10, 20]}, "name": "pack-1", "whatIsThat": "foo"}
while clicking the Remove packs
" LOG Reset DB done: undefined " getting this one
@sampathkumarch I am not sure I can manage to solve this problem. Perhaps, you can take a look at the local storage because I think offline map is located in that. Or you can ask @mfazekas
@thdailong thankyou for reply I was looked at local storage i didn't find the file. Can looking in that.
@mfazekas, @thdailong can you help me with this point, am unable to delete the offline maps in the app memory.