[英]How change information UILabel according to Tap on Google map marker ios
I am working with Google Map API for iOS . 我正在使用iOS的Google Map API 。 When I tap on the
marker
I present a view
which has label
where I want to display data according to tap location. 当我点击
marker
,会显示一个带有label
的view
,该label
要根据点击位置显示数据。 I want to change displayed data with tap but it is not working. 我想用点击更改显示的数据,但是它不起作用。 Anyone, please help me with this who worked on google map ios SDK.
任何人,请帮助我使用Google Map ios SDK的人。 Here is my code:
这是我的代码:
let tappedPosition = marker.position
let tappedLatitude = tappedPosition.latitude
let filteredBike = goBike.filter { $0.latitude == tappedLatitude }
let filteredBikeMakeName: String = filteredBike[0].bikeMakeName
let filteredBikeModelName: String = filteredBike[0].bikeModelName
if filteredBike.count > 0 {
goPullUpView.bikeModelLabel.text = "\(String(describing: filteredBikeMakeName)) \(String(describing: filteredBikeModelName))"
goPullUpView.bikeNumberLabel.text = filteredBike[0].regNo
}
func didTapMarker(_ mapView: GMSMapView, didTap marker: GMSMarker) {
let tappedPosition = marker.position
let tappedLatitude = tappedPosition.latitude
let filteredBike = goBike.filter { $0.location?.latitude == tappedLatitude }
if filteredBike.count > 0 {
// Do something
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.