I'm using the Google Maps API for iOS. I was doing some tests and set a UIView
as subclass of GMSMapView
and kept a pointer to it in ViewController
, getting:
#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
#import <CoreLocation/CoreLocation.h>
@interface ViewController : UIViewController<GMSMapViewDelegate, CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
}
@property (strong, nonatomic) IBOutlet GMSMapView *meuMapa;
@end
And I made its implementation in another class, like this:
-(GMSMapView*)criaMapa{
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition
cameraWithLatitude:-22.530351
longitude:-43.071199
zoom:17];
_mapaCriado = [GMSMapView mapWithFrame:CGRectZero camera:camera];
#pragma mark - Coloca Pinos no Mapa
// Uma posição em Niteroi
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-22.530303,-43.071033);
marker.title = @"Ponto B";
marker.snippet = @"Detalhes";
marker.map = _mapaCriado;
return _mapaCriado;
}
Returning in ViewController.m
in method -(void)viewDidLoad
I get the map that was created in another class:
- (void)viewDidLoad {
CriaMapas mapFact = [[CriaMapas alloc]init];
self.meuMapa = [mapFact criaMapa];
}
But the map is started with nothing, as if it had not started and no Marker creation.
How could I do this: Create the map in another class and return it to be displayed?