有没有办法让GSMAddress从placeID那里得到。我感兴趣的是使用从placeID方法获得的地址。
P.S:我有一个placeID,并想办法在iOS中得到相应的GMSAddress。
我找到了一个线程here,但这没有帮助。
谢谢,
发布于 2015-10-29 09:10:08
在自动完成之后,我们查找一个位置,然后将坐标传递给GMSGeocoder以检索详细信息,但我仍然缺少street_name和street_number。
CLLocationCoordinate2D addressCoordinates = CLLocationCoordinate2DMake(latitude,longitude);
GMSGeocoder* coder = [[GMSGeocoder alloc] init];
[coder reverseGeocodeCoordinate:addressCoordinates completionHandler:^(GMSReverseGeocodeResponse *results, NSError *error) {
if (error) {
NSLog(@"Error %@", error.description);
} else {
GMSAddress* address = [results firstResult];
NSLog(@"thoroughfare %@",address.thoroughfare);
NSLog(@"locality %@",address.locality);
NSLog(@"subLocality %@",address.subLocality);
NSLog(@"administrativeArea %@",address.administrativeArea);
NSLog(@"postalCode %@",address.postalCode);
NSLog(@"country %@",address.country);
NSLog(@"lines %@",address.lines);
}
}];我正在考虑切换到iOS自己的反地编码器。
[CLGeocoder reverseGeocodeLocation:[[CLLocation alloc] initWithLatitude:latitude longitude:longitude] completionHandler:
^(NSArray* placemarks, NSError* error) {发布于 2015-08-03 09:04:05
似乎没有从GMSPlace placeID直接获得GMSPlace的方法。
我发现的一种方法是使用GMSGeocoder().reverseGeocodeCoordinate方法和来自GMSPlace的coordinate属性。
我遵循的步骤可以概括为:
lookUpPlaceID方法查找coordinatescoordinates获得的lookUpPlaceID反向地形码守则如下:
placesClient?.lookUpPlaceID(placeID, callback: {
(place, error) -> Void in
// Get place.coordinate
GMSGeocoder().reverseGeocodeCoordinate(place!.coordinate, completionHandler: {
(response, error) -> Void in
for addObj in response.results() {
// Address object
}
})
})欢迎提出意见和更好的解决方案。
https://stackoverflow.com/questions/31781402
复制相似问题