Hi? I am working on a MapView app in Android. I have three markers that I want to be able to use the Google Map API getlocation-function on, later on. In order to try it out
Below is the answer to Kotlin Lover! It's quite very simple! As you can see below.
googleMap.addMarker(
MarkerOptions()
.position(latLatLng).draggable(true)
)
Below is the liner code for getting the end dragging location
mMap.setOnMarkerDragListener(object : GoogleMap.OnMarkerDragListener {
override fun onMarkerDragStart(arg0: Marker) {
}
override fun onMarkerDragEnd(arg0: Marker) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(arg0.position, 1.0f))
val message = arg0.position.latitude.toString() + "" + arg0.position.longitude.toString()
Log.d(TAG + "_END", message)
}
override fun onMarkerDrag(arg0: Marker?) {
val message = arg0!!.position.latitude.toString() + "" + arg0.position.longitude.toString()
Log.d(TAG + "_DRAG", message)
}
})
If you have any doubt then you can comment into the comment box! Happy Coding