Here I'm working on mapKitView
using GoogleMapKit
and here i want to do when the user drag the marker by using of didBeginDragging
, didDragging
and didEndDragging
and release the marker
at any location point of the screen. I found a helping content to fixed the marker in screen from Hugo Jordao's answer, but this only works to fixed marker position in the center of the screen only.So how can i set marker at any specific screen point??
- Dragging Method
func mapView(_ mapView: GMSMapView, didEndDragging marker: GMSMarker) {
if marker == mapMarker{
self.markerPosition = GMSCameraPosition(latitude: marker.position.latitude, longitude: marker.position.longitude, zoom: 5.0)
print("End Dragging")
}
}
- Set Marker center to the Screen
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
if self.markerPosition == nil{
mapMarker.position = position.target
}else{
mapMarker.position = self.markerPosition.target
}
}