Skip to content

Comments

Add option to store map tiles for offline missions#2085

Merged
ArturoManzoli merged 3 commits intobluerobotics:masterfrom
ArturoManzoli:792-Save-offline-map-tiles
Sep 29, 2025
Merged

Add option to store map tiles for offline missions#2085
ArturoManzoli merged 3 commits intobluerobotics:masterfrom
ArturoManzoli:792-Save-offline-map-tiles

Conversation

@ArturoManzoli
Copy link
Contributor

@ArturoManzoli ArturoManzoli commented Aug 25, 2025

  • Added option to download all map tiles on the current displayed area;
  • Downloads include tiles from the current zoom level up to the maximum zoom level.
  • Added a download status indicator (some downloads can take a while, specially on far zoom levels);
  • Tiles are shared between Mission Planning and the Map widget;
map_tiles.mp4

Closes #792

Signed-off-by: Arturo Manzoli <[email protected]>
@ArturoManzoli ArturoManzoli requested review from ES-Alexander and rafaellehmkuhl and removed request for rafaellehmkuhl August 25, 2025 18:00
Copy link
Member

@rafaellehmkuhl rafaellehmkuhl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems to be working great!

})

const esri = L.tileLayer(
const esri = tileLayerOffline(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also apply that to the other tiles (osm, seamarks and marineProfile)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll check for support and add those

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also apply that to the other tiles (osm, seamarks and marineProfile)?

Done!

@ArturoManzoli ArturoManzoli force-pushed the 792-Save-offline-map-tiles branch 2 times, most recently from b664697 to f9508f4 Compare September 15, 2025 13:29
Copy link
Member

@rafaellehmkuhl rafaellehmkuhl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the requested code change, I have a question: how can I test it?

I disabled my internet connection on master and re-opened Cockpit, and a section of the map was already there. Doing the same in this branch, the same section is there. It can be seen below:

Kapture.2025-09-17.at.12.27.46.mp4

saveCtl.addTo(map.value)
}

esri.on('savestart', (e: any) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this part of the code I assume the saving events are attached specific to the ESRI tiles, correct? That means, for example, that if the ESRI tiles downloading finish, but the others do not, and the user closes cockpit assuming they are all downloaded, the others will be not, right?

Can we do it in a way that it waits for all of them to be downloaded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library threats all layers in separate. If you want to download a specific one, you should implement a separate logic for that.

I have now implemented the option to download the other layers. Each one will be downloaded at a time.

@ArturoManzoli ArturoManzoli force-pushed the 792-Save-offline-map-tiles branch from f9508f4 to a9822a0 Compare September 22, 2025 20:46
@ArturoManzoli
Copy link
Contributor Author

On last patch

Besides the requested code change, I have a question: how can I test it?

I disabled my internet connection on master and re-opened Cockpit, and a section of the map was already there. Doing the same in this branch, the same section is there. It can be seen below:

Kapture.2025-09-17.at.12.27.46.mp4

You can test the feature by making a mission plan while online and then asking to download the tiles on the planning region.
After that, go offline and switch to Flight mode. All maps tiles will be available offline for the flight area.

@rafaellehmkuhl
Copy link
Member

rafaellehmkuhl commented Sep 22, 2025

On last patch

Besides the requested code change, I have a question: how can I test it?
I disabled my internet connection on master and re-opened Cockpit, and a section of the map was already there. Doing the same in this branch, the same section is there. It can be seen below:
Kapture.2025-09-17.at.12.27.46.mp4

You can test the feature by making a mission plan while online and then asking to download the tiles on the planning region. After that, go offline and switch to Flight mode. All maps tiles will be available offline for the flight area.

Ok. I've asked that because there was no clear change in behavior from master to this branch when using the application offline. As the video shows, if I go to around the zoom level that was used during the tiles downloading, it showed the map, but zooming out caused that are to go black. The same behavior happened on both master and this branch. I've tried resetting the Vite server by that time and nothing changed.

Did you try using those same steps on master to see if the same tiles do not show up? I'm asking myself if there's some caching involved that is already making tiles to be saved offline. It's strange.

Anyway I will try it again on Wednesday (I'm taking the day off tomorrow). If you have any extra instructions before that just let me know.

@ArturoManzoli
Copy link
Contributor Author

On last patch

Besides the requested code change, I have a question: how can I test it?
I disabled my internet connection on master and re-opened Cockpit, and a section of the map was already there. Doing the same in this branch, the same section is there. It can be seen below:
Kapture.2025-09-17.at.12.27.46.mp4

You can test the feature by making a mission plan while online and then asking to download the tiles on the planning region. After that, go offline and switch to Flight mode. All maps tiles will be available offline for the flight area.

Ok. I've asked that because there was no clear change in behavior from master to this branch when using the application offline. As the video shows, if I go to around the zoom level that was used during the tiles downloading, it showed the map, but zooming out caused that are to go black. The same behavior happened on both master and this branch. I've tried resetting the Vite server by that time and nothing changed.

Did you try using those same steps on master to see if the same tiles do not show up? I'm asking myself if there's some caching involved that is already making tiles to be saved offline. It's strange.

Anyway I will try it again on Wednesday (I'm taking the day off tomorrow). If you have any extra instructions before that just let me know.

Yes, the behavior you're seeing is expected. The tiles are saved starting from the current zoom level, when you press Download, up to the maximum zoom level at that location (the closest zoom). This approach is intentional, as higher zoom levels contain significantly more tiles, and including the outer levels would result in a massive and impractical download.

The idea is that the user selects a view that covers their entire work area, and Cockpit will download only the tiles necessary to ensure smooth operation within that region.

Copy link
Member

@rafaellehmkuhl rafaellehmkuhl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working nicely!

I was able to test it without doubts by adding a session.defaultSession.clearCache() in electron/main.ts, which force-cleaned the browser's cache, making it clear when the offline tiles from the library DB were working.

@ArturoManzoli ArturoManzoli merged commit e3c580c into bluerobotics:master Sep 29, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Store map tiles for offline map functionality

2 participants