Hi All,
I am trying to get the correct process for MarkerDragListener operation when there are multiple markers.
In the code below there are two markers and originally I "Dimensioned" a DragListener for each marker with a corresponding Sub for each marker-drag. I found that only one sub was called, and called when either marker was dragged.
1. Is this correct or have I missed something?
2. If correct how do I differentiate the markers for different Subs or different actions within the Sub.
Regards Roger
I am trying to get the correct process for MarkerDragListener operation when there are multiple markers.
In the code below there are two markers and originally I "Dimensioned" a DragListener for each marker with a corresponding Sub for each marker-drag. I found that only one sub was called, and called when either marker was dragged.
1. Is this correct or have I missed something?
2. If correct how do I differentiate the markers for different Subs or different actions within the Sub.
B4X:
Sub Map_Ready
Log("map ready")
gmap = mFragment.GetMap
If gmap.IsInitialized = False Then
ToastMessageShow("Error initializing map.", True)
Else
'Create BTSMarker Options including ICON
Dim BTSOptions As MarkerOptions
Dim BitmapDescriptor1 As BitmapDescriptor
Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
BTSOptions.Initialize
BTSOptions.Draggable(True)
BTSOptions.Position2(BTSLat, BTSLng).Snippet("pkt").Title("BASE")
BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("bts.png")
BTSOptions.Icon(BitmapDescriptor1)
'Creat BTS marker and "Drag" listener
BTSMarker=GoogleMapsExtras1.AddMarker(gmap, BTSOptions)
Dim BTSDragListener As OnMarkerDragListener
BTSDragListener.Initialize("BTSDragListener")
GoogleMapsExtras1.SetOnMarkerDragListener(gmap,BTSDragListener)
'Create LANDMarker Options including ICON
Dim LANDOptions As MarkerOptions
Dim BitmapDescriptor2 As BitmapDescriptor
Dim BitmapDescriptorFactory2 As BitmapDescriptorFactory
LANDOptions.Initialize
LANDOptions.Draggable(True)
LANDOptions.Position2(LANDLat, LANDLng).Snippet("pkt").Title("LANDMARK")
BitmapDescriptor2=BitmapDescriptorFactory2.FromAsset("landmark.png")
LANDOptions.Icon(BitmapDescriptor2)
'Creat LANDMarker marker and "Drag" listener
LANDMarker =GoogleMapsExtras1.AddMarker(gmap, LANDOptions)
'Dim LANDDragListener As OnMarkerDragListener
'LANDDragListener.Initialize("LANDDragListener")
'GoogleMapsExtras1.SetOnMarkerDragListener(gmap,LANDDragListener)
cp.Initialize2(MapLat, MapLng, MapZoom, MapBearing, 0 )
gmap.AnimateCamera(cp)
gmap.maptype = MapTypeInt
'MapTypeInt: 1=Road Map, 2=Satellite, 3=Terrain, 4=Satellite with Labels
gmap.GetUiSettings.CompassEnabled = False
End If
End Sub
Sub BTSDragListener_DragEnd(Marker1 As Marker)
'Log("DragEnd")
Dim BTSLatLng As LatLng
BTSLatLng = BTSMarker.Position
BTSLat = BTSLatLng.Latitude
BTSLng = BTSLatLng.Longitude
End Sub
Regards Roger