iphone - How to find the current location in google maps iOS? -


how can show in google maps current position of user?

do have read form gps?

to move current position have to:

self.googlemapsview.mylocationenabled = yes; 

then can setup key value observer in viewwillappear method , location update location manager of googlemaps sdk.

- (void)viewwillappear:(bool)animated {     [super viewwillappear:animated];      // implement here check if kvo implemented.     ...     [self.googlemapsview addobserver:self forkeypath:@"mylocation" options:nskeyvalueobservingnew context: nil] } 

and observe property.

- (void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context {     if ([keypath isequaltostring:@"mylocation"] && [object iskindofclass:[gmsmapview class]])     {         [self.googlemapsview animatetocameraposition:[gmscameraposition camerawithlatitude:self.googlemapsview.mylocation.coordinate.latitude                                                                                  longitude:self.googlemapsview.mylocation.coordinate.longitude                                                                                       zoom:self.googlemapsview.projection.zoom]];     } } 

do not forget deregister observer in viewwilldisappear.

- (void)viewwilldisappear:(bool)animated {     [super viewwilldisappear:animated];     // implement here if view has registered kvo     ...     [self.googlemapsview removeobserver:self forkeypath:@"mylocation"]; } 

based on weindl answer.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -