在地图上获取触摸位置

Get touch location on map

我正在使用以下代码在地图上查找触摸位置的纬度和经度-

-(void)handlePressRecognizer:(UIGestureRecognizer *)gestureRecognizer {
    for (PointAnnotation *ann in [mMapview annotations]) {
        if ([ann isKindOfClass:[PointAnnotation class]]) {
            [mMapview removeAnnotation:ann];
        }
    }
    [mMapview removeAnnotations:[mMapview annotations]];
    CGPoint touchPoint = [gestureRecognizer locationInView:mMapview];
    CLLocationCoordinate2D touchMapCoordinate =
    [mMapview convertPoint:touchPoint toCoordinateFromView:gestureRecognizer.view];
    if (gpsLocation != nil) {
        gpsLocation = nil;
    }
    gpsLocation = [[CLLocation alloc]initWithLatitude:touchMapCoordinate.latitude longitude:touchMapCoordinate.longitude];
    [self performSelector:@selector(showLoadingView) withObject:nil afterDelay:0.001];
    [self performSelector:@selector(getGoogleAddressFromLocation:) withObject:gpsLocation afterDelay:0.1];


}

我将这些 lat/long 传递给 google API 以查找地址,但 google 给了我错误的位置和地址。

这是屏幕截图-

请帮忙找出这个问题。

我使用 google 地图 SDK 中的以下代码来获取点击位置-

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
    NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude);

    [mMapview clear];
    gpsLocation = [[CLLocation alloc]initWithLatitude:coordinate.latitude longitude:coordinate.longitude];

}

然后使用以下代码我将图钉放在该位置-

    GMSMarker *marker = [[GMSMarker alloc]init];

    marker.title = [responseDict valueForKey:@"address"];
    marker.snippet = [responseDict valueForKey:@"country"];
    self.addressString = [responseDict valueForKey:@"address"];
    marker.position = gpsLocation.coordinate;

    marker.map = mMapview;
    [mMapview setSelectedMarker:marker];

使用 mapkit,google 没有给我正确的水龙头位置,但是使用 google 地图,它的工作就像一个魅力。