1

I am using Google Maps to set the location choice of the user. The user can drag a marker to set the position on the map. What I find is that it is extremely difficult to make the marker move. Let me first show the small code that I have:

 mMap.setOnMarkerDragListener(object: GoogleMap.OnMarkerDragListener {
        override fun onMarkerDragEnd(p0: Marker?) {
            if (p0 != null) {
                newlat = p0.position.latitude
                newlong = p0.position.longitude
            }
}

Before this piece of code I have other routines which first sets a location of the map. The user can then fine tune the position by dragging the marker using the above code. That is my objective. But the marker is not always draggable. It is extremely unpredicatbale when the marker would drag, when it would not. Is there any easier way of doing this?

To Give a better explanation of my problem. In my system, the user first manually enters the address details. In my other routines, Google Map searches for this address and puts the marker at the position. But I have seen that there is usually an error in this. So I am providing the user a final chance to fine tune the position using the draggable feature. While the drag is sometimes successful, it is very difficult to move the marker.

oTwo
  • 185
  • 2
  • 13

1 Answers1

1

Instead of dragging , you can just point the center of the view and place a marker there and for better understanding for user, you can create a cross hair or put a imageView over the map view and use marker image for it . also you can get help from this post

Alireza Sharifi
  • 1,127
  • 1
  • 9
  • 18
  • To Give a better explanation of my problem. In my system, the user first manually enters the address details. In my other routines, Google Map searches for this address and puts the marker at the position. But I have seen that there is usually an error in this. So I am providing the user a final chance to fine tune the position using the draggable feature. While the drag is sometimes successful, it is very difficult to move the marker. – oTwo Jun 16 '19 at 07:26
  • it the same thing . user drag the marker to aim on exact place? in my scenario user drag the map and aim with dummy imageview which is in center of map and you can put market in center of map through map API. i don't see any problem with that. at the end you just need a long-lat so... – Alireza Sharifi Jun 16 '19 at 07:32
  • Getting back to this question after a hiatus. Your answer is the best way to address this issue without a jerk. However, only one thing is bothering me, when I zoom into the map, the centre of the map view changes. As a result the marker changes position. Any thought on how to address this – oTwo Jun 28 '19 at 02:58
  • you can use `Map.setOnCameraChangeListener` after map zoomed or moved to get the center of it and put marker . tell us if this works for you – Alireza Sharifi Jun 30 '19 at 04:01