Android Question problems with googlemaps example: marked location not centered

toby

Well-Known Member
Licensed User
Longtime User
I've followed the instructions as precisely as I could when building the example app which is attached; all you need is to set your api key.

I noticed that the map shown is always the same regardless the location of the marker. Try set the marker to anywhere in Australia and it would be out of sight. The map should center around the marker. What I did were wrong? How to achieve that?

Secondly, I want the app to zoom in automatically so that street names are visible. What I should do?


Unfiltered Logs:

toby
b4a 7.80, windows 10, hp 15 bw008ca, asus zenfone 2
 

Attachments

  • b4a.googlemaps.zip
    9.6 KB · Views: 242

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub MapFragment1_Ready
    gmap = MapFragment1.GetMap
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    gmap.MyLocationEnabled = Result
    Dim m1 As Marker = gmap.AddMarker(10, 30, "test")
    m1.Snippet = "This is the snippet"

    ' New
    Dim campos As CameraPosition
    campos.Initialize(10,30,15) ' Lat, lon, zoom
    gmap.AnimateCamera(campos)
    
    
    
End Sub
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
Thanks to DonManfred, now the map centers around the marker at right zoom level.

The only problem I have is the marked location is a few hundred kms away from the correct spot. The attached example demonstrates that problem (the intended location is the white house, washington DC, USA). I'm now at loss to know to do next. Could someone kindly point me to the right direction?

 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
Solution: use google map with fused location provider. I have no idea why the other example works for me, but not this one. My app needs FLP anyway.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…