B4A Library GoogleMapsExtras

GoogleMapsExtras is an ongoing project to implement more of the Google Maps Android v2 classes in Basic4Android.

Currently the library allows you to create these objects:

Tutorials for each object will be uploaded to the Google Maps Android v2 tutorial thread.



  • GoogleMapsExtras_v1_71.zip
    59.6 KB · Views: 2,666
  • MapsForgeTileProvider_v1.01.zip
    173.1 KB · Views: 2,553
  • GoogleMapsExtras_v2_0_library_files.zip
    82.5 KB · Views: 2,963
Last edited:
I've tried to use Street View but I got this error:
java.lang.NoSuchMethodError: No virtual method getStreetViewPanorama()Lcom/google/android/gms/maps/StreetViewPanorama; in class Lcom/google/android/gms/maps/StreetViewPanoramaView; or its super classes (declaration of 'com.google.android.gms.maps.StreetViewPanoramaView' appears in base.apk)
at uk.co.martinpearman.b4a.com.google.android.gms.maps.StreetViewPanoramaView.GetStreetViewPanorama(StreetViewPanoramaView.java:29)
Please..Is there anyway to fix it? because I really NEED it..


Active Member
Licensed User
OK here's my first version of a wrapper for the KML packages in the Android Maps Utils.
The classes and methods i have wrapped so far are:

Author: Martin Pearman
Version: 0.01
  • KMLLayer
    • AddLayerToMap
    • GetContainers As List
    • GetPlacemarks As List
    • HasContainers As Boolean
    • HasPlacemarks As Boolean
    • Initialize (GoogleMap1 As GoogleMap, InputStream1 As InputStream)
    • Initialize2 (GoogleMap1 As GoogleMap, ResourceId As Int)
    • IsInitialized As Boolean
    • IsLayerOnMap As Boolean
    • RemoveLayerFromMap
    • Properties:
    • Map As GoogleMap
  • KmlContainer
    • GetContainers As List
      Gets a List of nested KmlContainers.
    • GetPlacemarks As List
      Gets a List of KmlPlacemarks.
    • GetProperty (PropertyName As String) As String
      Gets a single property value for the given property name.
    • GetStyle (StyleId As String) As KmlStyle
      Gets a style for the given id.
    • HasContainers As Boolean
    • HasPlacemarks As Boolean
    • HasProperties As Boolean
    • HasProperty (PropertyName As String) As Boolean
    • IsInitialized As Boolean
    • Properties:
    • ContainerId As String [read only]
      Gets the Container ID if it is specified.
    • Properties As Map [read only]
      Gets a Map where Map Keys are property names and Map Values are property values.
  • KmlPlacemark
    • GetId As String
    • GetProperty (Property As String) As String
    • HasGeometry As Boolean
    • HasProperties As Boolean
    • HasProperty (Property As String) As Boolean
    • IsInitialized As Boolean
    • Properties:
    • InlineStyle As KmlStyle [read only]
    • MarkerOptions As MarkerOptions [read only]
    • PolygonOptions As PolygonOptions [read only]
    • PolylineOptions As PolylineOptions [read only]
    • StyleId As String [read only]
  • KmlStyle
    • IsInitialized As Boolean
    • SetLineStringWidth (Width As Float)
      Sets the width of the LineString in screen pixels.
    • SetMarkerHotspot (X As Float, Y As Float, xUnits As String, yUnits As String)
      Sets the hotspot / anchor point of a marker.
    • SetMarkerRotation (Rotation As Float)
      Sets the rotation / heading of the Point in degrees clockwise about the marker's anchor.
    • SetPolygonFillColor (FillColor As Int)
    • SetPolygonStrokeWidth (StrokeWidth As Float)
      Sets the stroke width of the Polygon in screen pixels.
    • Properties:
    • Rotation As Float [read only]
      Gets the rotation of a marker in degrees clockwise about the marker's anchor.

A simple b4a project that loads a KML file from file assets - works for me though the web based infowindow content of the KML is a fail!

#Region  Project Attributes
   #ApplicationLabel: Android Maps Utils
   #VersionCode: 1
   'SupportedOrientations possible values: unspecified, landscape or portrait.
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: False
   '   GoogleMaps additional jar
   #AdditionalJar: com.google.android.gms:play-services-maps
#End Region

#Region  Activity Attributes
   #FullScreen: False
   #IncludeTitle: True
#End Region

Sub Process_Globals

End Sub

Sub Globals
   Dim GoogleMap1 As GoogleMap
   Dim MapFragment1 As MapFragment
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If Not(MapFragment1.IsGooglePlayServicesAvailable) Then
     Log("Google Play Services is not available")
     ToastMessageShow("Google Play Services is not available", False)
   End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub MapFragment1_Ready
   If GoogleMap1.IsInitialized Then
     Dim CameraPosition1 As CameraPosition
     CameraPosition1.Initialize(52.7523, 0.4049, 10)
     Dim KMLLayer1 As KMLLayer
     KMLLayer1.Initialize(GoogleMap1, File.OpenInput(File.DirAssets, "75116131-1-KML0.simple.kml"))
     If KMLLayer1.HasContainers Then
       Dim Containers As List=KMLLayer1.GetContainers
       '   TODO
     End If
     If KMLLayer1.HasPlacemarks Then
       Dim Placemarks As List=KMLLayer1.GetPlacemarks
       '   TODO
     End If
     Log("Error initializing GoogleMap")
     ToastMessageShow("Error initializing GoogleMap", False)
   End If
End Sub

I'll attach this first version of my library, the simple demo project and a temporary updated version of GoogleMapsExtras for you all to have a look at.

I shall release a proper update to GoogleMapsExtras over the next week - if you want to try AndroidMapsUtils and use the MarkerOptions object then overwrite you current GoogleMapsExtras jar and xml files with the temporary ones.

Thanks a lot, once i found the latest version of the play services jar i was able to get SLC to work.
Let's liase later in the week to turn this into a shared collaboration.

i code:
    If KML.HasContainers Then
		Dim C1 As List = KML.GetContainers
		Dim C2 As KmlContainer = C1.Get(0)
	End If
and get error: java.lang.RuntimeException: java.lang.ClassCastException: uk.co.martinpearman.b4a.androidmapsutils.data.kml.KmlContainer cannot be cast to com.google.maps.android.data.kml.KmlContainer
Help me please.!