gpt4 book ai didi

dart - 从坐标获取阿拉伯语地址行

转载 作者:IT王子 更新时间:2023-10-29 06:34:21 24 4
gpt4 key购买 nike

我正在使用 Geocoder用于获取地址行、国家/地区、邮政编码……的插件,如下所示:

  final coordinates = new Coordinates(26.328446, 50.153868);
var addresses = await Geocoder.local.findAddressesFromCoordinates(coordinates);
var first = addresses.first;
print(addresses);
print("${first.featureName} : ${first.addressLine}");

这会返回:

flutter: Zarqa Al Yamamah Street : Zarqa Al Yamamah Street - Al Dana Al Jenobiah, Dhahran 34453, Saudi Arabia

我想得到相同的结果,但在阿拉伯语中......有没有办法用这个插件实现这个?或者有任何其他插件可以用阿拉伯语为我返回地址吗?

最佳答案

您可以获得语言代码arar-SA。所以你需要这样做:

Locale loc = new Locale("ar");
Geocoder geocoder = new Geocoder(this, loc);

或者这样

geocoder = new Geocoder(this, Locale.ar_SA))

你的代码可以是这样的

           Locale loc = new Locale("ar"); 
Geocoder geocoder = new Geocoder(this, loc))
final coordinates = new Coordinates(26.328446, 50.153868);
var addresses = await Geocoder.local.findAddressesFromCoordinates(coordinates);
var first = addresses.first;
print(addresses);
print("${first.featureName} : ${first.addressLine}");

这样做:

Geocoder geocoder;
List<Address> addresses;
geocoder = new Geocoder(this, Locale.ar_SA))



addresses = geocoder.getFromLocation(latitude, longitude, 1); // Here 1 represent max location result to returned, by documents it recommended 1 to 5

String address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
String city = addresses.get(0).getLocality();
String state = addresses.get(0).getAdminArea();
String country = addresses.get(0).getCountryName();
String postalCode = addresses.get(0).getPostalCode();
String knownName = addresses.get(0).getFeatureName(); // Only if available else return NULL

看这个例子:

import 'package:locales/locales.dart';
import 'package:locales/currency_codes.dart';
import 'package:intl/intl.dart';

void main() {
final locale = Locale.ar_SA;
final currencyCode = CurrencyCode.sar;
final format = NumberFormat.simpleCurrency(
locale: '$locale', name: '$currencyCode', decimalDigits: 2);
print(locale);
print(currencyCode);
print(format.format(123.456));
}

https://github.com/jifalops/locales

关于dart - 从坐标获取阿拉伯语地址行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54284136/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com