没有得到适当的当前地址谷歌地图SDK的iOS
我正在使用googlemap sdk,但无法正确地在设备上找到当前位置,如goole map。
当我在浏览器中粘贴这个纬度和经度时,我得到了正确的经度和纬度,我得到了House No.的正确的完整地址,但没有在GMSAddress中获得House No.。 这是我的代码:
(void)viewWillAppear:(BOOL)animated {[mapView_ addObserver: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我的位置]; // ... 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);
}
}];
}}