Android Question B4A GoogleMapsExtra problem

cwt

Active Member
Licensed User
Longtime User
I am trying to implement GoogleMapsExtra in my Android app. I had no problem implementing it in my iOS app.

All I need out of GoogleMapsExtra is the ZoomToPoints method so I can display all Markers on a map within the boundarys of the map.

Below is the code in the GoogleMapsExtra class module:

B4X:
'version 2.10
Sub Class_Globals
    Private gm As GoogleMap
    Private no As JavaObject
End Sub

Public Sub Initialize (Gmap As GoogleMap)
    gm = Gmap
    no = Me
End Sub

Public Sub ZoomToPoints(Points As List)
    Dim bounds As Object = no.RunMethod("createBoundsIncluding:", Array(Points))
    Dim update As JavaObject
    update = update.InitializeStatic("GMSCameraUpdate").RunMethod("fitBounds:withPadding:", Array(bounds, 10))
    Dim gmapNo As JavaObject = gm
    gmapNo.RunMethod("animateWithCameraUpdate:", Array(update))
End Sub
When I run the code below from my map activity I get a runtime exception:
B4X:
Sub MapFragment1_Ready
    Try
        Dim ThisLatitude As String
        Dim ThisLongitude As String
        Dim MarkerColor As Float = 120.0
        Dim MarkerCount As Int = 0
        Dim MarkerList As List
        MarkerList.Initialize
       
        gmap = MapFragment1.GetMap
        rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
       
        Dim RS1 As ResultSet = Main.SQL1.ExecQuery("SELECT * FROM " & Main.TableName_LeadRecord & " WHERE lead_no_customer = 1 AND lead_yardsign_add_this = 1  ORDER BY ID DESC" )
        Do While RS1.NextRow
            ThisLatitude = RS1.GetString("lead_latitude")
            ThisLongitude = RS1.GetString("lead_longitude")
            If ThisLatitude <> "" And ThisLongitude <> "" Then
                Dim m1 As Marker = gmap.AddMarker2(ThisLatitude,ThisLongitude,RS1.GetString("lead_number"),MarkerColor)
                MarkerCount = MarkerCount + 1
                Dim MarkerPosition As LatLng
                Dim Lat As Double = RS1.GetString("lead_latitude")
                Dim Lon As Double = RS1.GetString("lead_longitude")
                MarkerPosition.Initialize(Lat,Lon)
                MarkerList.Add(MarkerPosition)
            End If
        Loop
        RS1.Close
        Dim cp As CameraPosition
        cp.Initialize(ThisLatitude,ThisLongitude, 14)
        gmap.AnimateCamera(cp)
        GMX.Initialize(gmap)
        GMX.ZoomToPoints(MarkerList) 'fit all markers within map border
        Label_MapAddress.Text = "Yardsign Count: " & MarkerCount
    Catch
        Log(LastException)
        xui.MsgboxAsync("Map Error: " & LastException, "Error")
    End Try
End Sub
This is the exception coming from the ZoomToPoints method in the GoogleMapsExtra class module:

(RuntimeException) java.lang.RuntimeException: Method: createBoundsIncluding: not found in: CommPayPro.App.googlemapsextras

This is the line from GMX ZoomToPoints causing the exception: Dim bounds As Object = no.RunMethod("createBoundsIncluding", Array(Points))

What am I missing here? Is there something missing (createBoundsIncluding) in my GoogleMaps library? Thanks.
 

cwt

Active Member
Licensed User
Longtime User
figured it out using this thread link:

 
Upvote 0
Top