elevation method

Future<Response<InlineResponse200>> elevation({
  1. BuiltList<String>? locations,
  2. BuiltList<String>? path,
  3. num? samples,
  4. CancelToken? cancelToken,
  5. Map<String, dynamic>? headers,
  6. Map<String, dynamic>? extra,
  7. ValidateStatus? validateStatus,
  8. ProgressCallback? onSendProgress,
  9. ProgressCallback? onReceiveProgress,
})

The Elevation API provides a simple interface to query locations on the earth for elevation data. Additionally, you may request sampled elevation data along paths, allowing you to calculate elevation changes along routes. With the Elevation API, you can develop hiking and biking applications, positioning applications, or low resolution surveying applications. Elevation data is available for all locations on the surface of the earth, including depth locations on the ocean floor (which return negative values). In those cases where Google does not possess exact elevation measurements at the precise location you request, the service interpolates and returns an averaged value using the four nearest locations. Elevation values are expressed relative to local mean sea level (LMSL). Requests to the Elevation API utilize different parameters based on whether the request is for discrete locations or for an ordered path. For discrete locations, requests for elevation return data on the specific locations passed in the request; for paths, elevation requests are instead sampled along the given path.

Implementation

Future<Response<InlineResponse200>> elevation({
  BuiltList<String>? locations,
  BuiltList<String>? path,
  num? samples,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _request = RequestOptions(
    path: r'/maps/api/elevation/json',
    method: 'GET',
    headers: <String, dynamic>{
      ...?headers,
    },
    queryParameters: <String, dynamic>{
      if (locations != null) r'locations': locations,
      if (path != null) r'path': path,
      if (samples != null) r'samples': samples,
    },
    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,
    ),
  );

  const _responseType = FullType(InlineResponse200);
  final _responseData = _serializers.deserialize(
    _response.data,
    specifiedType: _responseType,
  ) as InlineResponse200?;

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