Können wir die "Nachbenachrichtigung" für Standortaktualisierungen verwenden, um den aktuellen Standort auf Google Maps zu plotten? Oder eine andere Möglichkeit, etwas anderes zu implementieren? Obwohl ich KVO für @ "Mylocations" in googlemaps nicht verwenden möchte.Ist es zulässig, nach der Benachrichtigung zu verwenden, um Standortaktualisierungen zu verfolgen?
In LocationTracker.m
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
for(int i=0;i<locations.count;i++)
{
CLLocation * newLocation = [locations objectAtIndex:i];
CLLocationCoordinate2D theLocation = newLocation.coordinate;
CLLocationAccuracy theAccuracy = newLocation.horizontalAccuracy;
[PlacesDetails sharedInstance].theLocation=theLocation;
if(newLocation != nil && (!(theLocation.latitude == 0.0 && theLocation.longitude == 0.0)))
{
self.myLastLocation = theLocation;
self.myLastLocationAccuracy= theAccuracy;
// Below implemented the post notification
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateLocation" object:nil];
}
}
}
In ViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateGMSCameraPostition) name:@"updateLocation"
object:nil];
}
-(void)updateGMSCameraPostition
{
NSLog(@"CALLED UPDATELOCATION OBSERVER");
mapView_.camera = [GMSCameraPosition cameraWithTarget:[PlacesDetails sharedInstance].theLocation
zoom:14];}
Es ist eine legitime Art der Datenübermittlung. Genannt das Beobachtermuster, wenn Sie es nachschlagen möchten. – AMAN77
@ AMAN77 Ich habe das KVO-Muster verwendet, aber abstürzt und Konsole sagt "GMSMapView wurde freigegeben, während Schlüssel Wert Beobachter noch damit registriert waren" Ich habe das gleiche wie in Link 'http://stackoverflow.com/questions/27193946/ crash-while-my-location-on-googlemaps-on-iphone 'und probierte jede Lösung von dort aus. Also entschied ich mich, KVO nicht zu benutzen. – Ketan