因此,使用Google Maps相对较新,我不知道自己在做什么错。当我关注Google Maps - iOS documentation时。在“摄像机位置”的小标题下,我使用了以下代码块:
- (void)mapView:(GMSMapView *)mapView
idleAtCameraPosition:(GMSCameraPosition *)cameraPosition {
id handler = ^(GMSReverseGeocodeResponse *response, NSError *error) {
if (error == nil) {
GMSReverseGeocodeResult *result = response.firstResult;
GMSMarker *marker = [GMSMarker markerWithPosition:cameraPosition.target];
marker.title = result.lines[0];
marker.snippet = result.lines[1];
marker.map = mapView;
}
};
[geocoder_ reverseGeocodeCoordinate:cameraPosition.target completionHandler:handler];
}
主要问题是最后一行。
[geocoder_ reverseGeocodeCoordinate:cameraPosition.target completionHandler:handler];
由于Xcode给我以下错误-“使用未声明的标识符'geocoder_'”
为什么会这样呢?
最佳答案
您需要声明变量geocoder_
:
GMSGeocoder *geocoder_ = [GMSGeocoder geocoder];
oji https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_geocoder