-convertPoint:toCoordinateFromView:适用于iOS的Google Maps SDK的方法 [英] -convertPoint:toCoordinateFromView: method for Google Maps SDK for iOS
本文介绍了-convertPoint:toCoordinateFromView:适用于iOS的Google Maps SDK的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何实现MapKit方法
How do I implement the MapKit method
[googleMapView convertPoint:nePoint toCoordinateFromView:pinView];
在iOS版Google Maps SDK中?
in Google Maps SDK for iOS?
推荐答案
您可以使用以下内容:
GMSMapView* mapView = ...;
CGPoint point = ...;
...
CLLocationCoordinate2D coordinate =
[mapView.projection coordinateForPoint: point];
在这种情况下,point
应该相对于地图视图.
In this case point
should be relative to the map view.
如果您有一个相对于另一个视图的点(例如,在您的情况下为pinView
),则需要先将其转换为相对于地图视图的点.您可以执行以下操作:
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];
这篇关于-convertPoint:toCoordinateFromView:适用于iOS的Google Maps SDK的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文