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?
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.
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.
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.
To remove a marker from the map, call the setMap() method passing null as the argument. marker. setMap(null);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With