mapbox / mapbox/mapbox-maps-flutter
Tile Region estimate is 0 on Android
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 380
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
When trying to estimate a region, it works on iOS and returns the size in bytes. But on Android it returns 0 for transfer size and estimate size.
Tested on 2.5.1.
Our code looks like this:
```dart
/// Returns the number of bytes that are the estimated transfer size.
Future estimateTransferRegionSize({
required String styleUri,
required MapRegionMetaData metaData,
}) async {
TileRegionEstimateResult estimate =
await _tileStoreService.estimateRegionSize(
regionId: _generateRegionId(metaData.polygon, metaData.zoomRange),
styleUri: styleUri,
metaData: metaData,
);
// Returns 0 on Android
print(estimate.storageSize);
// Returns 0 on Android
print(estimate.transferSize);
return estimate.transferSize;
}
Future estimateRegionSize({
required String regionId,
required String styleUri,
required MapRegionMetaData metaData,
void Function(TileRegionEstimateProgress)? progressListener,
}) async {
TileStore store = await _tileStore.get();
TileRegionLoadOptions loadOptions = _getLoadOptions(styleUri, metaData);
return store.estimateTileRegion(
regionId,
loadOptions,
_getEstimateOptions(),
progressListener,
);
}
TileRegionLoadOptions _getLoadOptions(
String styleUri,
MapRegionMetaData metaData,
) {
/// Needed because https://github.com/mapbox/mapbox-maps-flutter/issues/846,
/// can be removed when 2.6.0 got released.
TilesetDescriptorOptions tilesetDescriptorOptions =
_getTilesetDescriptorOptions(styleUri, metaData.zoomRange);
Map geometryJson = metaData.polygon.toJson()
..remove('bbox');
return TileRegionLoadOptions(
acceptExpired: true,
networkRestriction: NetworkRestriction.NONE,
geometry: geometryJson,
metadata: metaData.toJson(),
extraOptions: {'test': 3},
startLocation:
Point(coordinates: metaData.polygon.coordinates.first.first),
descriptorsOptions: [tilesetDescriptorOptions],
);
}
```
An example of the metadata looks like this:
```
{updated_at: 1738085493503, created_at: 1738085493503, polygon: {type: Polygon, coordinates: [[[-0.00007829435426742748, 0.0002035126051964653], [0.00012067678505900403, -0.00016614456038155367], [-0.00007829435426742748, -0.00016614456038155367], [0.00012067678505900403, 0.0002035126051964653], [-0.00007829435426742748, 0.0002035126051964653]]]}, name: Ostsee, min_zoom: 0, max_zoom: 13}
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Android behavior through estimateRegionSize and estimateTileRegion using the supplied polygon, zoom range, and load options; compare the result with iOS, where both sizes are returned. Trace the TileRegionEstimateResult values through the Dart and Android implementation. Done means the Android transfer and storage estimates are populated for the reported region.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, dart, flutter
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100