-convertPoint:toCoordinateFromView: method for Google Maps SDK for iOS

Solutions Collect From Internet About “-convertPoint:toCoordinateFromView: method for Google Maps SDK for iOS”

You could use something like this:

GMSMapView* mapView = ...;
CGPoint point = ...;
...
CLLocationCoordinate2D coordinate = 
    [mapView.projection coordinateForPoint: point];

In this case point should be relative to the map view.

If you have a point relative to another view (eg pinView in your case), you’d need to convert that into a point relative to the map view first. You could do that with the following:

UIView* pinView = ...;
CGPoint pinViewPoint = ...;
...
CGPoint mapViewPoint = [pinView convertPoint: pinViewPoint toView: mapView];

So combining it all together:

GMSMapView* mapView = ...;
UIView* pinView = ...;
CGPoint pinViewPoint = ...;
...
CGPoint mapViewPoint = [pinView convertPoint: pinViewPoint toView: mapView];
CLLocationCoordinate2D coordinate = 
    [mapView.projection coordinateForPoint: mapViewPoint];