Android Question Show marks in map

jgimenez

Member
Hello
I'm having trouble displaying latitude and longitude markers in an app. Lat and long are stored ina a SQLite database
I create an activity (named mapas) with this code, but it shows me a blank map
1662403383772.png

Activity Name: mapas
One MapFragment (MapFragment1)
My code:

Marks In Map:
#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.
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 gmap As GoogleMap
    Dim M1 As Marker
   
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("mapa")
End Sub

Sub Activity_Resume
    Try
        Wait For gmap_Ready
        gmap = MapFragment1.GetMap
        Dim latitud As Double
        Dim longitud As Double
        Dim registro As ResultSet=Main.SQL1.ExecQuery("Select id, latitud, longitud from coordenadas")
        Do While registro.NextRow
            latitud= registro.GetString("latitud")
            longitud=registro.GetString("longitud")
            M1  = gmap.AddMarker(latitud, longitud,"BACHE")
            ToastMessageShow(latitud, True)
        Loop
        registro.Close
    Catch
        MsgboxAsync("Se produjo el error : "& LastException.Message,"Error")
    End Try
End Sub

Sub MapFragment1_Ready
    gmap = MapFragment1.GetMap  
    gmap.MyLocationEnabled = True
End Sub

But i dont show what is wrong.
Please help me.
Thanks!
 
Last edited:
Solution
I solve the problem
Maps SDK for Android was disabled on Google cloud platform, I needed to enable it before using the key
and I use the wrong key
Thanks por for your help!!!

DonManfred

Expert
Licensed User
Longtime User
You are not requesting Runtimepermissions. It is mandatory if you want to set MyLocationEndabled to true.
Don´t know what else you forgot.

Check https://www.b4x.com/android/forum/threads/google-maps.63930/#content
What is your manifesttext?

Best is to upload a small project showing the problem. You can replace the api-key in manifest with a dummy for uploading though.

A empty map is usually based on a wrong or missing Apikey in the Manifest.
Check the unfiltered log.
 
Last edited:
Upvote 0

jgimenez

Member
Thanks.
I test de example project , show empty map.
My Manifest:
manifest:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddManifestText(<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
)
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)

AddApplicationText(
<meta-data
  android:name="com.google.android.geo.API_KEY"
  android:value="AIzaSyCmFHamGE0O0BvxxxxxxxxXbTCSrjFVg-Q"/>
)
AddApplicationText(
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
)
 
Upvote 0

jgimenez

Member
I solve the problem
Maps SDK for Android was disabled on Google cloud platform, I needed to enable it before using the key
and I use the wrong key
Thanks por for your help!!!
 
Upvote 0
Solution
Top