Serge Nova
Member
Hello everyone, here is my code:
but I get this error:
Some suggestions?
B4X:
#Region Project Attributes
#ApplicationLabel: Marker Clustering
#VersionCode: 1
#VersionName: 1.0
#End Region
#AdditionalJar: google-play-services
#AdditionalJar: android-maps-utils-3.8.2-javadoc
Sub Process_Globals
Private MapFragment As MapFragment
Private GoogleMap As GoogleMap
End Sub
Sub Globals
Private MarkerClusterManager As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
MapFragment.Initialize("MapFragment", 1)
Activity.AddView(MapFragment, 0, 0, 100%x, 100%y)
End Sub
Sub MapFragment_Ready
GoogleMap = MapFragment.GetMap
InitializeClusterManager
AddMarkersToCluster
End Sub
Sub InitializeClusterManager
MarkerClusterManager = CreateClusterManager
End Sub
Sub CreateClusterManager As JavaObject
Dim context As JavaObject
context.InitializeContext
Dim jo As JavaObject
jo.InitializeNewInstance("com.google.maps.android.clustering.ClusterManager", Array(context, GoogleMap))
Return jo
End Sub
Sub AddMarkersToCluster
For i = 1 To 100
Dim position As LatLng
position.Initialize(Rnd(-90, 90), Rnd(-180, 180))
Dim marker As JavaObject
marker.InitializeNewInstance("com.google.maps.android.clustering.ClusterItem", Null)
marker.SetField("mPosition", position)
MarkerClusterManager.RunMethod("addItem", Array(marker))
Next
MarkerClusterManager.RunMethod("cluster", Null)
Fin Sub
but I get this error:
B4X:
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.google.maps$android$clustering$ClusterManager
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1719)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.ClassNotFoundException: com.google.maps$android$clustering$ClusterManager
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:289)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:84)
at b4a.identity.b4xmainpage$ResumableSub_load.resume(b4xmainpage.java:352)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1717)
... 8 more
Some suggestions?