Android Question Google Maps - How to add "onMarkerDragEnd"

jtare

Active Member
Licensed User
Longtime User
Reading the official documentation for Google Maps I found that is possible to add the "onMarkerDragEnd" event, but is not available in the b4a library of google maps, I wonder if it is possible to add the event with java code, something like this:
B4X:
#If Java
public void onMarkerDragEnd (com.google.android.gms.maps.model.Marker marker) {
    if (processBA.subExists("gmap_MarkerDragged")) {
        processBA.raiseEvent2(null, true, "gmap_MarkerDragged", false, (marker));
    }
}
#End If

Obviously the code above does not work, I believe it is missing the part of declaring the event listener (setOnMarkerDragListener)

I also tried:
B4X:
#If Java
public void startListener(com.google.android.gms.maps.GoogleMap mMap){
    mMap.setOnMarkerDragListener(new OnMarkerDragListener() {
        @Override
          public void onMarkerDragEnd(Marker marker) { 
        if (processBA.subExists("gmap_MarkerDragged")) {
        processBA.raiseEvent2(null, true, "gmap_MarkerDragged", false, (marker));
        }
        }
    });
}
#End If
But it doesn't even compile.

Any idea on how to do this?

Documentation:
 

TILogistic

Expert
Licensed User
Longtime User
see:
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Public GoogleMap1 As GoogleMap
Public GoogleMapsExtras1 As GoogleMapsExtras
Public MarkerExtras1 As MarkerExtras

B4X:
    Dim MarkerDrag As Marker
    MarkerDrag.Draggable = True
    MarkerDrag = GoogleMap1.AddMarker3(MapLatitude, MapLongitude, Null, MKBitmap)
    
    'Id Marker
    Dim IdMarker As String = MarkerExtras1.GetId(MarkerDrag)

B4X:
    Dim DragListener1 As OnMarkerDragListener
    DragListener1.Initialize("DragListener1")
    GoogleMapsExtras1.SetOnMarkerDragListener(GoogleMap1,DragListener1)

1620715878210.png
 
Last edited:
Upvote 0
Top