Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get marker position before dragging?

In Google Maps API v2, I want to store the previous location before dragging a marker, however, when I begin dragging the marker, it will always jump to some upper location, so in callback onMarkerDragStart, I can't get the last position.

Is it a bug, or can any fix the problem?

like image 708
Flybywind Avatar asked Feb 17 '13 15:02

Flybywind


People also ask

How do you move a marker smoothly?

There is a method makeMarker() you just need to call from onMapReady() method . There is two method rotateMarker() and moveVechile() to rotate and move marker. Hope this will help you.

What is a place marker on Google Maps?

A marker identifies a location on a map. By default, a marker uses a standard image. Markers can display custom images, in which case they are usually referred to as "icons." Markers and icons are objects of type Marker . You can set a custom icon within the marker's constructor, or by calling setIcon() on the marker.

What is a marker position?

A position marker consists of a point, a leader line, and multiline text. You can use the multi-functional grips to lengthen the leader line or change the position of the multiline text. You can control the size of a position marker with the GEOMARKPOSITIONSIZE system variable.

How to remove marker in google map API?

To remove a marker from the map, call the setMap() method passing null as the argument. marker. setMap(null);


1 Answers

the fact that the marker "Jumps" is because otherwise you could not see the marker due to the finger over it. In order to get the marker position, you should keep it saved before start dragging. The documentation is pretty clear:

Called when a marker starts being dragged. The marker's location can be accessed via getPosition(); this position may be different to the position prior to the start of the drag because the marker is popped up above the touch point.

So the idea is to keep the position "cached" and get them from this cached variable when dragging starts.

like image 189
N Dorigatti Avatar answered Oct 02 '22 12:10

N Dorigatti