Android Question Google Map

RUNO

Active Member
Licensed User
I tried to use @Erel code from this link
https://www.b4x.com/android/forum/threads/google-maps-position-without-animated.79520/#post-503491
but the following error appeared

** Activity (map_loc) Resume **
Error occurred on line: 38 (Map_loc)
com.google.maps.api.android.lib6.common.apiexception.c: MyLocation layer not enabled
at com.google.maps.api.android.lib6.common.m.bcom.google.android.gms.dynamite_mapsdynamite@201216065@20.12.16 (100400-0):6)
at com.google.maps.api.android.lib6.impl.bi.jcom.google.android.gms.dynamite_mapsdynamite@201216065@20.12.16 (100400-0):2)
at com.google.android.gms.maps.internal.i.acom.google.android.gms.dynamite_mapsdynamite@201216065@20.12.16 (100400-0):137)
 

DonManfred

Expert
Licensed User
Where is your projectupload showing the problem?
At least you should post ALL RELEVANT CODE if you expect someone to give any congrete answer!

Based on the error you have DISABLED myLocation. DID you enabled the myLocation layer?

DID you added tthis to your manifest?
B4X:
CreateResourceFromFile(Macro, Core.NetworkClearText)
See
 
Last edited:

MarcoRome

Expert
Licensed User
Where you have this code:

B4X:
        If gmap.MyLocation.IsInitialized=True Then
        .....
change in
B4X:
        gmap.MyLocationEnabled = True
        If gmap.MyLocation.IsInitialized=True Then
        ......
 

RUNO

Active Member
Licensed User
Thanks all , but camera not move to my location .
Camera position still a far from my location ,I used that code for move camera to my location.
 

RUNO

Active Member
Licensed User
Show us the relevant code

Post your activity create code
Post the code in MapFragment1_Ready
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("maplayout1")
    
    ''''''''''''''''''''''''''''''''''
   Panel1.Visible = False
   If gmap.IsInitialized = False Then
     Wait For MapFragment1_Ready
     gmap = MapFragment1.GetMap
  
   End If
    ProgressDialogShow2("Waiting for location...", True)
    gmap.MyLocationEnabled=True
    Do While gmap.MyLocation.IsInitialized = False
        Sleep(600)
    Loop
    Dim cp As CameraPosition
    cp.Initialize(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude, 15)
    gmap.MoveCamera(cp)

    Panel1.Visible = True
    ProgressDialogHide


End Sub
 
Top