placePhoto method

Future<Response<Uint8List>> placePhoto(
  1. String photoReference, {
  2. num? maxheight,
  3. num? maxwidth,
  4. CancelToken? cancelToken,
  5. Map<String, dynamic>? headers,
  6. Map<String, dynamic>? extra,
  7. ValidateStatus? validateStatus,
  8. ProgressCallback? onSendProgress,
  9. ProgressCallback? onReceiveProgress,
})

The Place Photo service, part of the Places API, is a read- only API that allows you to add high quality photographic content to your application. The Place Photo service gives you access to the millions of photos stored in the Places database. When you get place information using a Place Details request, photo references will be returned for relevant photographic content. Find Place, Nearby Search, and Text Search requests also return a single photo reference per place, when relevant. Using the Photo service you can then access the referenced photos and resize the image to the optimal size for your application. Photos returned by the Photo service are sourced from a variety of locations, including business owners and user contributed photos. In most cases, these photos can be used without attribution, or will have the required attribution included as a part of the image. However, if the returned photo element includes a value in the html_attributions field, you will have to include the additional attribution in your application wherever you display the image.

Implementation

Future<Response<Uint8List>> placePhoto(
  String photoReference, {
  num? maxheight,
  num? maxwidth,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _request = RequestOptions(
    path: r'/maps/api/place/photo',
    method: 'GET',
    responseType: ResponseType.bytes,
    headers: <String, dynamic>{
      ...?headers,
    },
    queryParameters: <String, dynamic>{
      r'photo_reference': photoReference,
      if (maxheight != null) r'maxheight': maxheight,
      if (maxwidth != null) r'maxwidth': maxwidth,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {
          'type': 'apiKey',
          'name': 'ApiKeyAuth',
          'keyName': 'key',
          'where': 'query',
        },
      ],
      ...?extra,
    },
    validateStatus: validateStatus,
    contentType: 'application/json',
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  dynamic _bodyData;

  final _response = await _dio.request<dynamic>(
    _request.path,
    data: _bodyData,
    options: Options(
      method: _request.method,
      sendTimeout: _request.sendTimeout,
      receiveTimeout: _request.receiveTimeout,
      extra: _request.extra,
      headers: _request.headers,
      responseType: _request.responseType,
      contentType: _request.contentType,
      validateStatus: _request.validateStatus,
      receiveDataWhenStatusError: _request.receiveDataWhenStatusError,
      followRedirects: _request.followRedirects,
      maxRedirects: _request.maxRedirects,
      requestEncoder: _request.requestEncoder,
      listFormat: _request.listFormat,
    ),
  );

  final Uint8List? _responseData = _response.data as Uint8List?;

  return Response<Uint8List>(
    data: _responseData,
    headers: _response.headers,
    isRedirect: _response.isRedirect,
    requestOptions: _response.requestOptions,
    redirects: _response.redirects,
    statusCode: _response.statusCode,
    statusMessage: _response.statusMessage,
    extra: _response.extra,
  );
}