メインコンテンツまでスキップ

Estimating Offline Usage

When using offline maps functionality in the Maps SDKs for iOS or Android, there is no mechanism for determining the storage size of offline map regions before downloading them. The number of tile packs and total storage required depends on several factors including the geographic area, zoom levels, map style complexity, and data density in the region.

Factors affecting offline storage size

Several factors influence the storage requirements for offline maps:

  • Geographic area: Larger regions require more storage
  • Zoom level range: Higher maximum zoom levels significantly increase storage requirements
  • Map style: Styles with more data layers (like satellite imagery) require more storage than simpler styles
  • Data density: Urban areas with more roads, buildings, and points of interest require more storage than rural areas
  • Coastlines and terrain: Complex coastlines and mountainous terrain can increase storage requirements

Testing offline scenarios in development

You can better understand your app's offline storage needs by testing different scenarios during development:

  1. Download test regions that represent typical use cases for your app
  2. Vary the parameters such as zoom levels, geographic area size, and map styles
  3. Measure the actual storage used by these test downloads
  4. Extrapolate from your test results to estimate production usage

Accessing storage information

Both the iOS and Android Maps SDKs provide methods to access the total storage size of offline regions after they have been downloaded.

iOS

On iOS, you can access the storage size using the TileRegion.completedResourceSize property:

tileStore.tileRegion(forId: regionId) { result in
switch result {
case .success(let tileRegion):
let sizeInBytes = tileRegion.completedResourceSize
let sizeInMB = Double(sizeInBytes) / (1024 * 1024)
print("Region size: \(String(format: "%.1f", sizeInMB)) MB")
case .failure(let error):
print("Failed to get region info: \(error)")
}
}

Android

On Android, you can access storage information through the TileRegion.completedResourceSize property:

tileStore.getTileRegion(regionId) { result ->
result.fold(
{ tileRegion ->
val sizeInBytes = tileRegion.completedResourceSize
val sizeInMB = sizeInBytes / (1024.0 * 1024.0)
println("Region size: %.1f MB".format(sizeInMB))
},
{ error ->
println("Failed to get region info: $error")
}
)
}

Best practices for production apps

  • Start with conservative estimates and allow users to download additional regions as needed
  • Provide clear storage information to users before they download regions
  • Implement storage management features to help users manage their downloaded content
  • Consider download over WiFi only for larger regions to avoid mobile data charges
このpageは役に立ちましたか?