/*
 * @Author: WuXiangNan
 * @Date: 2021-04-15 11:57:19
 * @LastEditors  : WuWei
 * @LastEditTime : 2022-01-18 20:59:39
 * @FilePath: /wisdom-huiguanjia-app/attendance_package/lib/src/service/impl/location_service_impl.dart
 * @Description: 
 */

import 'dart:async';

import 'package:app_package/app_package.dart';
import 'package:attendance_package/src/service/location_service.dart';
import 'package:dio/dio.dart' as _Dio; // TOD:因dio依赖库与flutter自带http库 有类命名冲突

class LocationServiceImpl implements LocationService {
  static String prefix = 'https://restapi.amap.com/v3';

  @override
  Future<Map<String, dynamic>?> getLocationName(parameters) async {
    var res = await HttpUtil.instance.get(
        '$prefix/geocode/regeo?key=09b98b5ab6138d96a3ff36bc1b0b9c6c&$parameters');

    _Dio.Response<dynamic> resp = res;

    Map? regeocodes = resp.data['regeocode'];

    return regeocodes as FutureOr<Map<String, dynamic>?>;
  }

  @override
  Future<List?> getDistance(parameters) async {
    var res = await HttpUtil.instance.get('$prefix/distance?$parameters');

    _Dio.Response<dynamic> resp = res;
    List? results = resp.data['results'];

    return results;
  }
}
