Android Question Place Picker in Google Map

AndroidMadhu

Active Member
Licensed User
Hello,
Is there is any library available for place picker at google map?
User wants to drag the place icon at google map to choose the place.


Please advice

Thanks
 

TILogistic

Expert
Licensed User
Longtime User
just drag and drop the marker.

Capturing the final position (latitude and longuitude) of the marker

and if you want to know the direction of the position, just do a geocode with google or OSRM api
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
there are different ways to do it.

The other way is to touch the marker and then touch on the map the location where you want to move it.


MapFragment1_MarkerClick

MapFragment1_Click or MapFragment1_LongClick
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
another way:

have the user press the marker and find the direction where they want to move the marker,
or find the address where you want to move the marker

You can use this which is very useful (Does not require Api-Key) to search for addresses or locations


note:
My users make thousands of inquiries for addresses and locations without limitations
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
something like this:

I am finding now too.

to do this you can use this:

GoogleMapExtras

B4X:
    Dim ListVisibleRegion As List
    ListVisibleRegion.Initialize
    ListVisibleRegion.Add(GoogleMapsExtras1.GetProjection(GoogleMap1).GetVisibleRegion.FarLeft)
    ListVisibleRegion.Add(GoogleMapsExtras1.GetProjection(GoogleMap1).GetVisibleRegion.FarRight)
    ListVisibleRegion.Add(GoogleMapsExtras1.GetProjection(GoogleMap1).GetVisibleRegion.NearRight)
    ListVisibleRegion.Add(GoogleMapsExtras1.GetProjection(GoogleMap1).GetVisibleRegion.NearLeft)


Calculate the centroid (Latitude and Longuitede) to move the marker as the user moves the map.

 
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
Perfect. Doit. Thanks Oparra and all forum (Erel alway the first)
I create a new mod ACTIVITY and put this code:

(IMPORTAN use api key from google in manifest)
This code make a zoom into map:
And is importan know this:


The layoutmap only have a button and mapframent objetc.





B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim Marca As Marker
    Public UltimaPosicion As  LatLng
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private MapFragment1 As MapFragment
    Private cmdAceptar As Button
    
    Private gmap As GoogleMap
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    
    Activity.LoadLayout("LayoutMapa")
    Wait For MapFragment1_Ready
    
    gmap = MapFragment1.GetMap
    
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        gmap.MyLocationEnabled = True
        
        Do While gmap.MyLocation.IsInitialized = False
            Log("Location not initialized... Sleep a while...")
            Sleep(250)
        Loop
        
        If gmap.MyLocation.IsInitialized Then
            Dim CameraPosition1 As CameraPosition            'CameraPosition1.Initialize2(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude, gmap.CameraPosition.Zoom, 0, 0)
            CameraPosition1.Initialize(gmap.MyLocation.Latitude,gmap.MyLocation.Longitude, 17)
            gmap.moveCamera(CameraPosition1)
        End If
        
        
    Else
        Log("Permiso no concedido")
        Activity.Finish
    End If
    Activity.Title = "Seleccione lugar"
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub






Private Sub cmdAceptar_Click
    Activity.Finish
End Sub

Private Sub MapFragment1_Click (Point As LatLng)
    cmdAceptar.Text=Point.Latitude &  " / " & Point.Longitude
    UltimaPosicion = Point
    
    gmap.Clear
    
    Marca = gmap.AddMarker(Point.Latitude,Point.Longitude,"Punto"   )
    
End Sub


In actity resume that call this actityty sel, i put:

B4X:
    Sub Activity_Resume
''    ...
        If frmMapaPicker.UltimaPosicion.IsInitialized Then
            B4XLatitud.Text = frmMapaPicker.UltimaPosicion.Latitude
            B4XLongitud.Text = frmMapaPicker.UltimaPosicion.Longitude
            frmMapaPicker.UltimaPosicion = Null
        Else
''...       
      end sub 
  
        'and a button to show mapapicker
        Private Sub cmdMapaPicker_Click
    StartActivity(frmMapaPicker)
End Sub
 
Upvote 0
Top