Ios 在谷歌地图上获取X和Y标记位置有困难吗?

Ios 在谷歌地图上获取X和Y标记位置有困难吗?,ios,swift,google-maps,google-maps-markers,Ios,Swift,Google Maps,Google Maps Markers,这些是我拥有的标记,单击它,就会调用委托方法,我想获得标记的x,y值,以便创建一个视图,其中说明该特定标记的一些信息。如何执行此操作?mapView:didTapMarker:是在点击标记后调用的委托函数。所以为了得到x和y的值,你需要这样做: let camera = GMSCameraPosition.camera(withLatitude: 36.80, longitude: 10.18, zoom: 2.0) let mapView = GMSMapView.map(withFrame:

这些是我拥有的标记,单击它,就会调用委托方法,我想获得标记的
x
y
值,以便创建一个视图,其中说明该特定标记的一些信息。如何执行此操作?

mapView:didTapMarker:是在点击标记后调用的委托函数。所以为了得到x和y的值,你需要这样做:

let camera = GMSCameraPosition.camera(withLatitude: 36.80, longitude: 10.18, zoom: 2.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.delegate = self
view = mapView

// Creates a marker in the center of the map.
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: 36.80, longitude: 10.18)
marker.title = "Tunis"
marker.snippet = "Tunisia"
marker.map = mapView
let position = CLLocationCoordinate2D(latitude: 51.5, longitude: -0.127)
let london = GMSMarker(position: position)
london.title = "London"
london.map = mapView
请注意,标记具有“位置”属性,“位置”是坐标对

请参阅参考资料以了解和

您可以使用x和y的值来获取标记的一些信息


或者,您可以使用在点击标记时向用户显示信息。

mapView:didTapMarker:是在点击标记后调用的委托函数。所以为了得到x和y的值,你需要这样做:

let camera = GMSCameraPosition.camera(withLatitude: 36.80, longitude: 10.18, zoom: 2.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.delegate = self
view = mapView

// Creates a marker in the center of the map.
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: 36.80, longitude: 10.18)
marker.title = "Tunis"
marker.snippet = "Tunisia"
marker.map = mapView
let position = CLLocationCoordinate2D(latitude: 51.5, longitude: -0.127)
let london = GMSMarker(position: position)
london.title = "London"
london.map = mapView
请注意,标记具有“位置”属性,“位置”是坐标对

请参阅参考资料以了解和

您可以使用x和y的值来获取标记的一些信息


或者,当您点击标记时,您可以使用向用户显示信息。

为什么不使用?如果您想将
坐标
转换为
CGPoint
,您可以使用
var point=mapView.projection.point(用于:marker.position)
。为什么不使用?如果要将
坐标转换为
CGPoint
,仍然可以使用
var point=mapView.projection.point(用于:marker.position)