getMapTile method

Future<GetMapTileResponse> getMapTile({
  1. required String mapName,
  2. required String x,
  3. required String y,
  4. required String z,
  5. String? key,
})
Retrieves a vector data tile from the map resource. 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.

The origin (0, 0) is the top left of the map. Increasing the zoom level by 1 doubles both the X and Y dimensions, so a tile containing data for the entire world at (0/0/0) will be split into 4 tiles at zoom 1 (1/0/0, 1/0/1, 1/1/0, 1/1/1).

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

Parameter mapName : The map resource to retrieve the map tiles from.

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 key : The optional API key to authorize the request.

Implementation

Future<GetMapTileResponse> getMapTile({
  required String mapName,
  required String x,
  required String y,
  required String z,
  String? key,
}) async {
  final $query = <String, List<String>>{
    if (key != null) 'key': [key],
  };
  final response = await _protocol.sendRaw(
    payload: null,
    method: 'GET',
    requestUri:
        '/maps/v0/maps/${Uri.encodeComponent(mapName)}/tiles/${Uri.encodeComponent(z)}/${Uri.encodeComponent(x)}/${Uri.encodeComponent(y)}',
    queryParams: $query,
    hostPrefix: 'maps.',
    exceptionFnMap: _exceptionFns,
  );
  return GetMapTileResponse(
    blob: await response.stream.toBytes(),
    cacheControl:
        _s.extractHeaderStringValue(response.headers, 'Cache-Control'),
    contentType:
        _s.extractHeaderStringValue(response.headers, 'Content-Type'),
  );
}