map-gl-offline 0.1.0-alpha.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -131
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +3177 -269
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3178 -268
- package/dist/index.js.map +1 -1
- package/dist/style.css +79 -0
- package/dist/ui/components/shared/LanguageSelector.d.ts +22 -0
- package/dist/ui/managers/PanelManager.d.ts +2 -0
- package/dist/ui/translations/ar.d.ts +182 -0
- package/dist/ui/translations/en.d.ts +181 -0
- package/dist/ui/translations/index.d.ts +61 -0
- package/dist/utils/icons.d.ts +1 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
> **⚠️ Development Notice**: This package is currently under active development and is optimized for **MapLibre GL JS**. Mapbox GL JS support is planned for future releases.
|
|
10
10
|
|
|
11
|
-
A comprehensive **TypeScript** library for **MapLibre GL JS** that enables complete offline map functionality with vector/raster tiles, styles, fonts, sprites, and glyphs stored in IndexedDB. Features include advanced analytics,
|
|
11
|
+
A comprehensive **TypeScript** library for **MapLibre GL JS** that enables complete offline map functionality with vector/raster tiles, styles, fonts, sprites, and glyphs stored in IndexedDB. Features include advanced analytics, intelligent cleanup, and a modern glassmorphic UI control.
|
|
12
|
+
|
|
13
|
+
## 🎬 Demo
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
*Download regions, load offline styles, and navigate maps without an internet connection.*
|
|
12
18
|
|
|
13
19
|
## ✨ Features
|
|
14
20
|
|
|
@@ -19,8 +25,6 @@ A comprehensive **TypeScript** library for **MapLibre GL JS** that enables compl
|
|
|
19
25
|
- 🔤 **Font & Glyph Support**: Comprehensive font and glyph management with Unicode range support
|
|
20
26
|
- 🎨 **Sprite Management**: Handle map sprites and icons offline with multi-resolution support (@1x, @2x)
|
|
21
27
|
- 📊 **Real-time Analytics**: Detailed storage analytics, performance metrics, and optimization recommendations
|
|
22
|
-
- 📤 **Import/Export**: Export regions to JSON, PMTiles, and MBTiles formats for data portability
|
|
23
|
-
- 🔄 **Data Portability**: Seamless transfer of offline maps between devices and applications
|
|
24
28
|
|
|
25
29
|
### 🎨 Modern UI Control
|
|
26
30
|
|
|
@@ -38,7 +42,6 @@ A comprehensive **TypeScript** library for **MapLibre GL JS** that enables compl
|
|
|
38
42
|
- ⚡ **Performance Optimized**: Concurrent downloads, async/await patterns, and memory-efficient operations
|
|
39
43
|
- 🧹 **Intelligent Cleanup**: Smart cleanup of expired data with customizable policies
|
|
40
44
|
- 🔄 **Robust Error Handling**: Comprehensive error recovery, retry mechanisms, and graceful degradation
|
|
41
|
-
- 🗜️ **Multiple Formats**: Support for JSON, PMTiles, and MBTiles export/import
|
|
42
45
|
- 🔍 **Enhanced Logging**: Detailed debugging with zoom-level specific logging (Z12 tracking)
|
|
43
46
|
|
|
44
47
|
## 📦 Installation
|
|
@@ -92,7 +95,7 @@ The UI control provides:
|
|
|
92
95
|
|
|
93
96
|
- 📍 **Polygon drawing** for region selection
|
|
94
97
|
- 📊 **Download progress** tracking
|
|
95
|
-
- 🗂️ **Region management** (view, delete
|
|
98
|
+
- 🗂️ **Region management** (view, delete)
|
|
96
99
|
- 🌓 **Theme toggle** (dark/light mode)
|
|
97
100
|
- 📈 **Storage analytics**
|
|
98
101
|
|
|
@@ -135,72 +138,6 @@ console.log(`Stored regions:`, regions);
|
|
|
135
138
|
await offlineManager.deleteRegion('downtown');
|
|
136
139
|
```
|
|
137
140
|
|
|
138
|
-
### Import/Export Functionality
|
|
139
|
-
|
|
140
|
-
Export and import offline regions for backup, sharing, or cross-device usage:
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
// Export region to JSON
|
|
144
|
-
const jsonExport = await offlineManager.exportRegionAsJSON('downtown', {
|
|
145
|
-
includeStyle: true,
|
|
146
|
-
includeTiles: true,
|
|
147
|
-
includeSprites: true,
|
|
148
|
-
includeFonts: true,
|
|
149
|
-
onProgress: progress => {
|
|
150
|
-
console.log(`Export: ${progress.percentage}% - ${progress.stage}`);
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// Download exported file
|
|
155
|
-
const url = URL.createObjectURL(jsonExport.blob);
|
|
156
|
-
const a = document.createElement('a');
|
|
157
|
-
a.href = url;
|
|
158
|
-
a.download = jsonExport.filename;
|
|
159
|
-
a.click();
|
|
160
|
-
URL.revokeObjectURL(url);
|
|
161
|
-
|
|
162
|
-
// Export to PMTiles (web-optimized format)
|
|
163
|
-
const pmtilesExport = await offlineManager.exportRegionAsPMTiles('downtown', {
|
|
164
|
-
compression: 'gzip',
|
|
165
|
-
metadata: { attribution: 'Custom map data', version: '1.0' },
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// Export to MBTiles (SQLite-based, industry standard)
|
|
169
|
-
const mbtilesExport = await offlineManager.exportRegionAsMBTiles('downtown', {
|
|
170
|
-
format: 'pbf',
|
|
171
|
-
compression: 'gzip',
|
|
172
|
-
metadata: { description: 'Offline map for mobile app' },
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Import region from file
|
|
176
|
-
const fileInput = document.querySelector('#fileInput');
|
|
177
|
-
fileInput.addEventListener('change', async event => {
|
|
178
|
-
const file = event.target.files?.[0];
|
|
179
|
-
if (file) {
|
|
180
|
-
const result = await offlineManager.importRegion({
|
|
181
|
-
file,
|
|
182
|
-
format: 'json', // or 'pmtiles', 'mbtiles'
|
|
183
|
-
overwrite: true,
|
|
184
|
-
newRegionId: 'imported-downtown',
|
|
185
|
-
newRegionName: 'Imported Downtown',
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
if (result.success) {
|
|
189
|
-
console.log(`Imported: ${result.regionId}`);
|
|
190
|
-
console.log(`Stats:`, result.statistics);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
**Export Format Comparison:**
|
|
197
|
-
|
|
198
|
-
| Format | Best For | Pros | Cons |
|
|
199
|
-
| ------- | ----------------------------- | ---------------------------------------- | ---------------------- |
|
|
200
|
-
| JSON | Development, debugging | Human-readable, easy to inspect | Larger file size |
|
|
201
|
-
| PMTiles | Web deployment, CDN | Efficient HTTP range requests, optimized | Specialized format |
|
|
202
|
-
| MBTiles | GIS tools, cross-platform use | SQLite-based, widely supported, mature | Requires SQLite parser |
|
|
203
|
-
|
|
204
141
|
### Analytics & Monitoring
|
|
205
142
|
|
|
206
143
|
```typescript
|
|
@@ -262,13 +199,6 @@ const manager = new OfflineMapManager(options?: {
|
|
|
262
199
|
- `getFontStats()` - Get font statistics
|
|
263
200
|
- `getSpriteStats()` - Get sprite statistics
|
|
264
201
|
|
|
265
|
-
**Import/Export Methods:**
|
|
266
|
-
|
|
267
|
-
- `exportRegionAsJSON(regionId: string, options?)` - Export to JSON format
|
|
268
|
-
- `exportRegionAsPMTiles(regionId: string, options?)` - Export to PMTiles format
|
|
269
|
-
- `exportRegionAsMBTiles(regionId: string, options?)` - Export to MBTiles format
|
|
270
|
-
- `importRegion(data: RegionImportData)` - Import from file (JSON/PMTiles/MBTiles)
|
|
271
|
-
|
|
272
202
|
**Maintenance Methods:**
|
|
273
203
|
|
|
274
204
|
- `cleanupOldTiles(maxAge: number)` - Remove tiles older than specified age
|
|
@@ -295,7 +225,7 @@ const control = new OfflineManagerControl({
|
|
|
295
225
|
|
|
296
226
|
- Interactive polygon drawing for region selection
|
|
297
227
|
- Real-time download progress tracking
|
|
298
|
-
- Region management (view, delete
|
|
228
|
+
- Region management (view, delete)
|
|
299
229
|
- Theme toggle (dark/light mode)
|
|
300
230
|
- Storage analytics display
|
|
301
231
|
- Responsive mobile-friendly design
|
|
@@ -318,38 +248,6 @@ interface OfflineRegionOptions {
|
|
|
318
248
|
}
|
|
319
249
|
```
|
|
320
250
|
|
|
321
|
-
### Import/Export Options
|
|
322
|
-
|
|
323
|
-
```typescript
|
|
324
|
-
interface ExportOptions {
|
|
325
|
-
includeStyle?: boolean; // Include style data (default: true)
|
|
326
|
-
includeTiles?: boolean; // Include tiles (default: true)
|
|
327
|
-
includeSprites?: boolean; // Include sprites (default: true)
|
|
328
|
-
includeFonts?: boolean; // Include fonts (default: true)
|
|
329
|
-
onProgress?: (progress: ExportProgress) => void;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
interface PMTilesExportOptions extends ExportOptions {
|
|
333
|
-
compression?: 'gzip' | 'brotli' | 'none';
|
|
334
|
-
clustered?: boolean;
|
|
335
|
-
metadata?: Record<string, any>;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
interface MBTilesExportOptions extends ExportOptions {
|
|
339
|
-
format?: 'pbf' | 'png' | 'jpg';
|
|
340
|
-
compression?: 'gzip' | 'none';
|
|
341
|
-
metadata?: Record<string, any>;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
interface RegionImportData {
|
|
345
|
-
file: File;
|
|
346
|
-
format: 'json' | 'pmtiles' | 'mbtiles';
|
|
347
|
-
overwrite?: boolean;
|
|
348
|
-
newRegionId?: string;
|
|
349
|
-
newRegionName?: string;
|
|
350
|
-
}
|
|
351
|
-
```
|
|
352
|
-
|
|
353
251
|
## 🎯 Use Cases
|
|
354
252
|
|
|
355
253
|
- 🏔️ **Outdoor & Recreation Apps**: Hiking, camping, and adventure apps with offline trail maps
|
|
@@ -361,7 +259,6 @@ interface RegionImportData {
|
|
|
361
259
|
- 🎓 **Educational Apps**: Geography and learning apps with downloadable maps
|
|
362
260
|
- 🏗️ **Construction & Engineering**: Site management with offline blueprints
|
|
363
261
|
- 💾 **Bandwidth Optimization**: Reduce data costs by pre-downloading maps
|
|
364
|
-
- 🔄 **Multi-Device Sync**: Share offline maps across devices and platforms
|
|
365
262
|
|
|
366
263
|
## 💡 Best Practices
|
|
367
264
|
|
|
@@ -446,23 +343,6 @@ if (navigator.storage?.persist) {
|
|
|
446
343
|
}
|
|
447
344
|
```
|
|
448
345
|
|
|
449
|
-
### Import/Export Issues
|
|
450
|
-
|
|
451
|
-
```typescript
|
|
452
|
-
// Validate file before import
|
|
453
|
-
const validFormats = ['json', 'pmtiles', 'mbtiles'];
|
|
454
|
-
const ext = file.name.split('.').pop();
|
|
455
|
-
if (!validFormats.includes(ext)) {
|
|
456
|
-
throw new Error(`Unsupported format: ${ext}`);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// Handle large files
|
|
460
|
-
if (file.size > 100 * 1024 * 1024) {
|
|
461
|
-
// 100MB
|
|
462
|
-
console.warn('Large file - import may take time');
|
|
463
|
-
}
|
|
464
|
-
```
|
|
465
|
-
|
|
466
346
|
### Performance Issues
|
|
467
347
|
|
|
468
348
|
```typescript
|
|
@@ -562,7 +442,6 @@ map-gl-offline/
|
|
|
562
442
|
- ✅ **Fractional Zoom Fix**: Fixed tile loading at fractional zoom levels
|
|
563
443
|
- ✅ **Modern UI**: Glassmorphic design with dark/light theme
|
|
564
444
|
- ✅ **Polygon Drawing**: Interactive region selection tool
|
|
565
|
-
- ✅ **Import/Export**: JSON, PMTiles, and MBTiles support
|
|
566
445
|
- ✅ **Enhanced Analytics**: Comprehensive storage insights
|
|
567
446
|
- ✅ **Performance**: Optimized downloads and memory usage
|
|
568
447
|
- ✅ **TypeScript**: Full type safety throughout
|
|
@@ -572,7 +451,6 @@ See [CHANGELOG.md](CHANGELOG.md) for complete version history.
|
|
|
572
451
|
## 🙏 Acknowledgments
|
|
573
452
|
|
|
574
453
|
- [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js) - Open-source map rendering engine
|
|
575
|
-
- [PMTiles](https://github.com/protomaps/PMTiles) - Cloud-optimized map tile format
|
|
576
454
|
- [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) - Browser storage API
|
|
577
455
|
- [Tilebelt](https://github.com/mapbox/tilebelt) - Tile coordinate utilities
|
|
578
456
|
|
package/dist/index.d.ts
CHANGED
|
@@ -15,3 +15,5 @@ export * from './types';
|
|
|
15
15
|
export * from './utils';
|
|
16
16
|
export { OfflineMapManager as default } from './managers/offlineMapManager';
|
|
17
17
|
export { OfflineManagerControl } from './ui/offlineManagerControl';
|
|
18
|
+
export { i18n, t } from './ui/translations';
|
|
19
|
+
export type { SupportedLanguage, TranslationKey } from './ui/translations';
|