草庐IT

ios - GMSServices GMSGeocoder reverseGeocodeCoordinate IOS返回结果的语言

coder 2024-01-24 原文

我有两个成对使用的应用程序,都使用 GMSServices 的 GMSGeocoder 进行反向地理编码坐标搜索。但在第一个结果中,结果以英语显示,在其他结果中以设备本地语言显示。设备相同

我查了很多,发现现在没有办法让GMSGeocoder使用指定语言的结果。这是不可能的,我们应该改用 google API 请求。但它以某种方式起作用,我不知道如何让第二个应用程序仅以英语返回结果。

类似的问题 mapView - 同一设备上的不同语言。

如何在不考虑设备本地化的情况下为 GMSServices 设置英语?

最佳答案

GMSGeocoder 向您发送了县名,但没有发送国家/地区 ISO 代码。

您可以使用 native CLGeocoder 类从纬度和经度获取 counytyISOcode。例如:

CLLocation *location = (your location)
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:
    ^(NSArray* placemarks, NSError* error){
        if ([placemarks count] > 0)
        {
            CLPlacemark *placemark = [placemarks objectAtIndex:0];
            NSLog(@"Your counry is %@",placemark. ISOcountryCode);
        }
}];

关于ios - GMSServices GMSGeocoder reverseGeocodeCoordinate IOS返回结果的语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31924147/

有关ios - GMSServices GMSGeocoder reverseGeocodeCoordinate IOS返回结果的语言的更多相关文章

随机推荐