getBoundingBox method
Returns the geographic area covered by this datastore.
Returns the bounding box defining the extent of available map data
Implementation
@override
Future<BoundingBox> getBoundingBox() async {
if (_boundingBox != null) return _boundingBox!;
final List<Datastore> datastoresList = datastores.toList();
// Fetch all boundaries in parallel, using the cache when available.
final List<Future<BoundingBox>> futures = [];
for (Datastore datastore in datastoresList) {
BoundingBox? boundingBox = _datastoreBoundaries[datastore];
futures.add(boundingBox != null ? Future.value(boundingBox) : datastore.getBoundingBox());
}
final List<BoundingBox> boundaries = await Future.wait(futures);
for (int i = 0; i < datastoresList.length; ++i) {
Datastore datastore = datastoresList[i];
BoundingBox boundingBox = boundaries[i];
_datastoreBoundaries[datastore] = boundingBox;
if (null == _boundingBox) {
_boundingBox = boundingBox;
} else {
_boundingBox = _boundingBox!.extendBoundingBox(boundingBox);
}
}
return _boundingBox!;
}