小编use*_*384的帖子

如何从reverseGeocodeCoordinate获得国家,州,城市?

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添加到了应用密钥.控制台中未打印错误.有了这个,我的意思是我不知道线条的内容.

reverse-geocoding ios google-maps-sdk-ios

24
推荐指数
2
解决办法
3万
查看次数

GMSMapView中的内存泄漏

我创建了一个简单的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不允许我发布它.如果有兴趣,我可以通过电子邮件发送给某人

我做错了什么或错过了什么?

google-maps-sdk-ios

6
推荐指数
1
解决办法
3225
查看次数