geocodeGPS static method
经纬度地理编码
Implementation
static Future<GeocodeEntity> geocodeGPS(double lat, double lon, {String pathHead = 'assets/'}) async {
_pathHead = pathHead;
var data = GeocodeEntity(
province: '',
city: '',
district: '',
provinceId: '',
cityId: '',
districtId: '',
latitude: lat,
longitude: lon,
);
// 省
final province = await _getProvince(lat, lon);
data = data.copyWith(province: province.name, provinceId: province.id);
// 市
final city = await _getCity(lat, lon, data.provinceId);
data = data.copyWith(city: city.name, cityId: city.id);
// 区/县
final district = await _getDistrict(lat, lon, data.cityId);
data = data.copyWith(district: district.name, districtId: district.id);
return data;
}