I am currently working with the Google Maps API for iOS. I drew markers on maps, but I don’t know how to “update” (delete markers and redraw new) markers after the user enters new data from another class. I am trying to call the map display class as follows:
This is code in another class (GetInfoViewController) that runs when a user enters new data
MapViewController *mapVC = [[MapViewController alloc]init]; [mapVC resetMap];
This is what is inside the MapViewController
- (void)viewDidLoad { [super viewDidLoad]; mapView.myLocationEnabled = YES; mapView.settings.myLocationButton = YES; getpos = [[NSMutableArray alloc]init]; } - (void)loadView { lat = [[NSMutableArray alloc]init]; lng = [[NSMutableArray alloc]init]; markers = [[NSMutableArray alloc]init]; locationManager = [[CLLocationManager alloc] init]; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
In GetInfoViewController: changing the contents of a container in a MapViewController
MapViewController *viewController1 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc1"]; viewController1.view.frame = self.container.bounds; [viewController1 willMoveToParentViewController:self]; [self.container addSubview:viewController1.view]; [self addChildViewController:viewController1]; [viewController1 didMoveToParentViewController:self]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.container cache:YES]; [UIView commitAnimations];
source share