GMSReverseGeocodeResponse 包含
- (GMSReverseGeocodeResult *)firstResult;
Run Code Online (Sandbox Code Playgroud)
其定义如下:
@interface GMSReverseGeocodeResult : NSObject<NSCopying>
/** Returns the first line of the address. */
- (NSString *)addressLine1;
/** Returns the second line of the address. */
- (NSString *)addressLine2;
@end
Run Code Online (Sandbox Code Playgroud)
有没有办法从这两个字符串中获取国家,ISO国家代码,州(administrative_area_1或相应的一个)(对所有国家和所有地址都有效)?
注意:我试图执行这段代码
[[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(40.4375, -3.6818) completionHandler:^(GMSReverseGeocodeResponse *resp, NSError *error)
{
NSLog( @"Error is %@", error) ;
NSLog( @"%@" , resp.firstResult.addressLine1 ) ;
NSLog( @"%@" , resp.firstResult.addressLine2 ) ;
} ] ;
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,处理程序从未被调用过.我确实添加了应用密钥,并且还将iOS捆绑包ID添加到了应用密钥.控制台中未打印错误.有了这个,我的意思是我不知道线条的内容.
我创建了一个简单的UIViewController来创建和销毁GMSMapView.
- (void)viewDidAppear:(BOOL)animated
{
if ( !m_disappearing_bc_segue )
{
[super viewDidAppear:animated] ;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude: self.location.latitude
longitude: self.location.longitude
zoom:9 ] ;
m_mapView = [GMSMapView mapWithFrame:CGRectMake(0, 0, 320, 420) camera:camera];
m_mapView.myLocationEnabled = NO ;
[m_mapView setMapType: kGMSTypeTerrain] ;
m_mapView.delegate = self ;
[self.view addSubview:m_mapView] ;
[self.view sendSubviewToBack:m_mapView] ;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated] ;
[m_mapView clear] ;
[m_mapView stopRendering] ;
[m_mapView removeFromSuperview] ;
m_mapView = nil ;
}
Run Code Online (Sandbox Code Playgroud)
我使用了仪器和分配仪器.测试很简单.在UINavigation ViewController中,按下视图,回击并重复.每次推送和弹出包含上述GMSMapView的视图时,大约有40kb泄漏.我有一个来自仪器的截图来说明这一点,但stackoverflow不允许我发布它.如果有兴趣,我可以通过电子邮件发送给某人
我做错了什么或错过了什么?