- Introduced new MapLayerType for vector MBTiles. - Enhanced MapLayer class to handle vector-specific properties. - Implemented MBTilesService for managing MBTiles files, including import and deletion functionalities. - Updated MapManagementScreen to allow importing and managing MBTiles files. - Added UI components for displaying and interacting with MBTiles layers. - Integrated vector tile rendering in MapTab, supporting dynamic theme loading. - Updated pubspec.yaml to include necessary dependencies for MBTiles and vector tiles.
7.3 KiB
Vector Map Tiles with MBTiles - User Guide
This guide explains how to use offline vector map tiles in MeshCore SAR app.
Overview
The app now supports offline vector map tiles using the MBTiles format. Vector tiles provide:
- ✅ True Offline Maps: Work without any internet connection after initial import
- ✅ Smaller File Sizes: ~70% smaller than raster tiles (e.g., 150MB vs 500MB)
- ✅ Better Performance: Smooth zooming with over-zooming support
- ✅ Customizable Styles: Change map appearance without re-downloading tiles
- ✅ SAR-Optimized: Topographic styles ideal for search & rescue operations
Quick Start
1. Download MBTiles File
Download a vector tile MBTiles file for your region. Recommended sources:
Option A: Geofabrik (via MapTiler) - Recommended for Slovenia
URL: https://geodata.maptiler.download/extracts/osm/v3.11/2020-02-10/europe/osm-2020-02-10-v3.11_europe_slovenia.mbtiles
Schema: Shortbread
Size: ~150MB (Slovenia)
Option B: Protomaps - Global coverage
URL: https://maps.protomaps.com/builds/
Format: PMTiles (can be converted to MBTiles)
Option C: OpenMapTiles - Self-hosted
URL: https://openmaptiles.org/downloads/
Schema: OpenMapTiles
Requires: Account (free tier available)
2. Import MBTiles File
- Open Settings → Map Management
- Scroll to "Offline Vector Maps" section
- Tap "Import MBTiles File"
- Select your downloaded
.mbtilesfile - Wait for import to complete
3. Select Vector Layer
- Go to the Map tab
- Tap the Layers button (bottom-right)
- Select your imported vector map from the list
- The app will automatically download the appropriate style
4. Enjoy Offline Maps!
Your vector maps now work completely offline. No internet required!
Detailed Features
File Management
The Map Management screen shows:
- File Name: Name from MBTiles metadata
- File Size: Human-readable (KB/MB/GB)
- Format: PBF (vector) or PNG/JPG (raster)
- Zoom Levels: Min and max zoom supported
- Geographic Bounds: Coverage area coordinates
- Vector Schema: Shortbread, OpenMapTiles, or Unknown
Actions:
- Expand Card: Tap to see full metadata
- Delete: Tap delete button (confirmation required)
- Refresh: Tap refresh icon to reload list
Supported Vector Schemas
Shortbread (Geofabrik)
- Best for: European regions, SAR operations
- Style Source: versatiles.org
- Compatible MBTiles: Geofabrik extracts
- Compression: Gzipped PBF data
OpenMapTiles
- Best for: Global coverage, detailed mapping
- Style Source: openmaptiles.org or custom
- Compatible MBTiles: OpenMapTiles downloads
- Compression: Standard PBF data
Map Styles
Vector tile styles are automatically downloaded from:
Versatiles (Shortbread):
https://tiles.versatiles.org/assets/styles/colorful.json
Features:
- Topographic contours
- Road classification
- Building outlines
- Natural features (forests, water)
- POI markers
Technical Details
Storage Location
iOS: /Documents/offline_maps/
Android: /data/data/com.meshcore.sar/files/offline_maps/
Supported Formats
- Vector: PBF (Protocol Buffer Format), MVT (Mapbox Vector Tile)
- Compression: Auto-detected gzip compression
- Schema: Shortbread, OpenMapTiles, or custom
Performance
Slovenia Example (Geofabrik):
- File Size: ~150MB
- Zoom Levels: 0-14
- Tile Count: ~500,000 tiles
- Load Time: <2 seconds
Comparison with Raster:
- Raster (same area, zoom 0-16): ~500MB
- Vector advantage: 70% smaller
Troubleshooting
Import Fails
Error: "Failed to import MBTiles file"
Solutions:
- Verify file is valid MBTiles format (use
mbtilesCLI to validate) - Check file permissions (ensure app can read the file)
- Ensure sufficient storage space available
- Try re-downloading the MBTiles file
Style Not Loading
Error: "Failed to load map style"
Solutions:
- Check internet connection (required for first-time style download)
- Wait and retry (remote servers may be temporarily down)
- Clear app cache and restart
- Verify MBTiles schema matches style (Shortbread vs OpenMapTiles)
Map Not Displaying
Symptoms: Blank map or only showing other layers
Solutions:
- Verify layer is selected in layer picker
- Check zoom level is within MBTiles zoom range
- Pan to area covered by MBTiles bounds
- Restart app to reload layers
Black Screen on Map
Cause: Vector theme not loaded yet
Solution: Wait for style download to complete (loading indicator shows progress)
Advanced Usage
Using Custom Styles
To use custom vector tile styles:
- Host your style JSON on a web server
- Modify
MapLayer.fromMbtilesFile()to use your style URL - Ensure style schema matches your MBTiles schema
Example style URL format:
https://your-server.com/styles/custom-sar-style.json
Converting Other Formats
PMTiles → MBTiles:
# Using tippecanoe
pmtiles extract region.pmtiles region.mbtiles
Shapefile → MBTiles:
# Using tippecanoe
tippecanoe -o output.mbtiles input.shp
Generating Custom MBTiles
Use Tilemaker to generate MBTiles from OSM data:
# Download OSM extract
wget https://download.geofabrik.de/europe/slovenia-latest.osm.pbf
# Generate MBTiles with Shortbread schema
tilemaker --input slovenia-latest.osm.pbf \
--output slovenia-custom.mbtiles \
--config shortbread.json \
--process shortbread.lua
References
Documentation
Tools
- Tilemaker - Generate MBTiles from OSM
- MBTiles CLI - Validate and inspect
- Tippecanoe - Convert and optimize tiles
Data Sources
- Geofabrik - OSM extracts
- Protomaps - Pre-generated PMTiles
- OpenMapTiles - Commercial and free options
FAQ
Q: Can I use multiple MBTiles files at once? A: Yes! Import multiple files and switch between them using the layer picker.
Q: Do I need internet after importing? A: Only for the first-time style download. After that, fully offline.
Q: What's the maximum file size? A: No hard limit. Tested with files up to 2GB successfully.
Q: Can I share MBTiles files between devices?
A: Yes! Export the .mbtiles file and import on another device.
Q: Do vector tiles work on iOS and Android? A: Yes! Fully supported on both platforms.
Q: How do I update map data? A: Download a new MBTiles file with updated data and import it.
Support
For issues or questions:
- GitHub Issues: meshcore-sar/issues
- Documentation: See CLAUDE.md for technical details
- Community: Join the MeshCore Slack/Discord
License
Vector map tiles implementation uses:
vector_map_tiles- MIT Licensevector_map_tiles_mbtiles- MIT License- Map data copyright OpenStreetMap contributors