我正在使用googlemap sdk但无法在设备上正确找到当前位置,就像在goole地图中一样 当我在浏览器中粘贴这个纬度和经度时,我得到了正确的经度和经度我正在使用House No.获得正确的完整地址,但没有在GMSAddress中获得House No.这是我的代码:
(void)viewWillAppear:(BOOL)animated { [mapView_addOserver:self forKeyPath:@“myLocation”options:0 context:nil]; }
(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if([keyPath isEqualToString:@“myLocation”]){ CLLocation * location = [object myLocation]; // ... NSLog(@“Location,%@,”,location);
CLLocationCoordinate2D target =
CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude);
lat=location.coordinate.latitude;
lon=location.coordinate.longitude;
[[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(lat, lon) completionHandler:^(GMSReverseGeocodeResponse* response, NSError* error) {
NSLog(@"reverse geocoding results:");
for(GMSAddress* addressObj in [response results])
{
NSDictionary*dict=[response results];
NSLog(@"coordinate.latitude=%f", addressObj.coordinate.latitude);
NSLog(@"coordinate.longitude=%f", addressObj.coordinate.longitude);
NSLog(@"thoroughfare=%@", addressObj.thoroughfare);
NSLog(@"locality=%@", addressObj.locality);
NSLog(@"subLocality=%@", addressObj.subLocality);
NSLog(@"administrativeArea=%@", addressObj.administrativeArea);
NSLog(@"postalCode=%@", addressObj.postalCode);
NSLog(@"country=%@", addressObj.country);
NSLog(@"lines=%@", addressObj.lines);
}
}];
} }