I'm new in iOS Development. I'm develop an app that have a maps inside it. I want to know how to handle Tap gesture when the user clicks on the map.
My apps workflow is when user clicks somewhere in maps, a marker will be shown and when marker is tapped, the marker will show an overlay detail about that address.
Here is my code to show a maps
import SwiftUI
import GoogleMaps
struct GoogleMapsView: UIViewRepresentable {
@ObservedObject var locationManager = LocationManager()
private let zoom: Float = 15.0
private let longitudeTest: CLLocationDegrees = 106.7587855
private let latitudeTest: CLLocationDegrees = -6.2715794
let marker : GMSMarker = GMSMarker()
func makeUIView(context: Self.Context) -> GMSMapView {
let camera = GMSCameraPosition.camera(withLatitude: latitudeTest, longitude: longitudeTest, zoom: zoom)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
return mapView
}
func updateUIView(_ mapView: GMSMapView, context: Context) {
marker.position = CLLocationCoordinate2D(latitude: latitudeTest, longitude: longitudeTest)
marker.title = "hay"
marker.snippet = "hello"
marker.map = mapView
mapView.animate(toLocation: CLLocationCoordinate2D(latitude: latitudeTest, longitude: longitudeTest))
}
}