getTile method

Future<GetTileResponse> getTile({
  1. required String tileset,
  2. required String x,
  3. required String y,
  4. required String z,
  5. List<TileAdditionalFeature>? additionalFeatures,
  6. String? key,
})

GetTile returns a tile. Map tiles are used by clients to render a map. They're addressed using a grid arrangement with an X coordinate, Y coordinate, and Z (zoom) level.

For more information, see Tiles in the Amazon Location Service Developer Guide.

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter tileset : Specifies the desired tile set. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only the vector.basemap value.

Valid Values: raster.satellite | vector.basemap | vector.traffic | raster.dem

Parameter x : The X axis value for the map tile.

Parameter y : The Y axis value for the map tile.

Parameter z : The zoom value for the map tile.

Parameter additionalFeatures : A list of optional additional parameters such as map styles that can be requested for each result. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

Parameter key : Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

Implementation

Future<GetTileResponse> getTile({
  required String tileset,
  required String x,
  required String y,
  required String z,
  List<TileAdditionalFeature>? additionalFeatures,
  String? key,
}) async {
  final $query = <String, List<String>>{
    if (additionalFeatures != null)
      'additional-features': additionalFeatures.map((e) => e.value).toList(),
    if (key != null) 'key': [key],
  };
  final response = await _protocol.sendRaw(
    payload: null,
    method: 'GET',
    requestUri:
        '/tiles/${Uri.encodeComponent(tileset)}/${Uri.encodeComponent(z)}/${Uri.encodeComponent(x)}/${Uri.encodeComponent(y)}',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return GetTileResponse(
    blob: await response.stream.toBytes(),
    pricingBucket: _s.extractHeaderStringValue(
        response.headers, 'x-amz-geo-pricing-bucket')!,
    cacheControl:
        _s.extractHeaderStringValue(response.headers, 'Cache-Control'),
    contentType:
        _s.extractHeaderStringValue(response.headers, 'Content-Type'),
    eTag: _s.extractHeaderStringValue(response.headers, 'ETag'),
  );
}