swift - SwiftUI 中的 GMSMarker 点击事件
问题描述
我在 UiViewRepresentable 结构中使用了 makeUiView() 和 updateUiView() 方法来创建我的地图视图。
struct GoogleMapView: UIViewRepresentable {
func updateUIView(_ uiView: GMSMapView, context: Context) {
let marker : GMSMarker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: 20, longitude: 50);
marker.map = uiView;
}
func makeUIView(context: Context) -> GMSMapView {
let camera = GMSCameraPosition.camera(withLatitude: 20, longitude: 50,zoom: 10)
let mapView = GMSMapView(frame: CGRect.zero, camera: camera)
mapView.delegate = ViewController()
return mapView
}
}
如果我单击地图上的标记,我想导航到不同的视图。我发现我必须为此使用 GMSMapViewDelegate 和 mapView() 函数。但目前我没有在我的项目中使用任何 ValueControler。还有在哪里制作mapView.delegate = 自我?
解决方案
推荐阅读
- python-3.x - 试图从嵌套列表理解中获取非嵌套列表
- python - 从列表列表中创建一个列表,对 enumerate 方法创建的每个列表使用相同的重复索引号
- r - 我尝试在 R 中读取 tsv 文件,但它会引发有关元素不匹配的错误
- java - 有没有办法从应用程序读取安卓手机上的传入通知?
- html - 如何使我的 html 文本容器更具响应性?
- amazon-web-services - 在 AWS Glue 中,如何将 resolveChoice 应用于 DynamicFrame 中数组内的结构元素?
- javascript - Javascript 没有在 Node.JS API 调用中创建新的函数实例
- node.js - AWS 上的 NodeJS 和反应应用程序部署:不呈现反应 UI
- java - 使用自定义音库将 MIDI 序列写入文件
- applescript - Applescript 发送带有签名的电子邮件