首页 新闻 会员 周边

关于mapkitView如何显示中文地名

0
悬赏园豆:10 [已关闭问题] 关闭于 2015-08-13 10:19
在做团购项目,使用了mapkit,不过它显示的都是中文拼音,当我获取的地理位置,发送请求后,因为city = Guangzho,直接报下面的错误:
2015-08-12 20:35:28.222 团[44689:2380177] Error Domain=Parameter value is invalid: city. (请求参数值无效: city) Code=10011 "The operation couldn’t be completed. (Parameter value is invalid: city. (请求参数值无效: city) error 10011.)" UserInfo=0x7c29af70 {errorMessage=Parameter value is invalid: city. (请求参数值无效: city), errorCode=10011}
2015-08-12 20:35:29.667 GATuan[44689:2380177] params : {
	longitude = 113.3684551059959,
	latitude = 23.11926916664753,
	city = Guangzho,
	radius = 500
}
请问如何mapkit显示中文地名呢?
求各路大神帮忙啊。
bonjour520的主页 bonjour520 | 菜鸟二级 | 园豆:204
提问于:2015-08-13 09:19
< >
分享
所有回答(2)
0

恩,找到了解决方法了。

#pragma mark - MKMapViewDelegate

//当用户的位置更新了就会调用

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{

    [self.coder reverseGeocodeLocation:userLocation.location completionHandler:^(NSArray *placemarks, NSError *error) {

        if (error || placemarks.count == 0) {

            return ;

        }

        CLPlacemark *pm = [placemarks firstObject];

        NSLog(@"pm %@",pm.locality);

        //城市,这个city是拼音的地名

        NSString *city = pm.locality ? pm.locality : pm.addressDictionary[@"state"];

        //转换成小写

        city = city.lowercaseString;

//定义过滤器

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"pinYin contains %@",city];

//self.cities:存储了所以的城市信息,从这个数组中搜索

        GACity *gaCity= [[self.cities filteredArrayUsingPredicate:predicate] firstObject];

        NSLog(@"city :%@",gaCity.name);

        self.city = gaCity.name;

    }];

}

bonjour520 | 园豆:204 (菜鸟二级) | 2015-08-13 10:18
0

请问你的self.cities是什么样的。能发给我吗,783513920@qq.com

sfsas | 园豆:202 (菜鸟二级) | 2016-08-29 01:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册