I\'m using the following code to create a map and attach a marker to it. I\'m also adding a marker listener where I need to get the longitude and latitude of the marker posi
Take a look at this function in your code.
@Override
public void onMarkerDragEnd(Marker marker) {
// TODO Auto-generated method stub
Toast.makeText(
MainActivity.this,
"Lat " + map.getMyLocation().getLatitude() + " "
+ "Long " + map.getMyLocation().getLongitude(),
Toast.LENGTH_LONG).show();
System.out.println("yalla b2a "
+ map.getMyLocation().getLatitude());
}
Here you are trying to get your current location on map which is wrong you should get location of marker that you dragged. You already have "marker" object here. Use that to get location of this draged marker's location.
LatLng position = marker.getPosition(); //
Toast.makeText(
MainActivity.this,
"Lat " + position.latitude + " "
+ "Long " + position.longitude,
Toast.LENGTH_LONG).show();