Android Question Google maps (or GoogleExtras) problem in rapid debug mode

Dario126

Member
Licensed User
Longtime User
Why this code:

B4X:
Dim tmpMarker As Marker
Dim gXtra As GoogleMapsExtras

tmpMarker=gXtra.AddMarker(gMap, mo)

works fine in normal compilation, but breaks in rapid debug mode with following error:

Error occurred on line: 561 (main)
java.lang.NullPointerException


at maps.e.bl.a(Unknown Source)
at maps.e.bl.a(Unknown Source)
at maps.e.al.a(Unknown Source)
at eif.onTransact(SourceFile:167)
at android.os.Binder.transact(Binder.java:310)
at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.addMarker(Unknown Source)
at com.google.android.gms.maps.GoogleMap.addMarker(Unknown Source)
at uk.co.martinpearman.b4a.googlemapsextras.GoogleMapsExtras.AddMarker(GoogleMapsExtras.java:48)


it's same if I use Google Map method to create Marker:

B4X:
gMap.AddMarker3(iHotSpot.Lat, iHotSpot.Lon, "stitle" , Null)
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm unable to reproduce it with GoogleMaps library.

I'm running this code in debug mode:
B4X:
#Region  Project Attributes
   #ApplicationLabel: B4A Example
   #VersionCode: 1
   #VersionName:
   'SupportedOrientations possible values: unspecified, landscape or portrait.
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: False
   #AdditionalRes: C:\android-sdk-windows7\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#End Region

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

'Activity module
Sub Process_Globals

End Sub

Sub Globals
  Dim mFragment As MapFragment
  Dim gmap As GoogleMap
  Dim MapPanel As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
  MapPanel.Initialize("")
  Activity.AddView(MapPanel, 0, 0, 100%x, 100%y)
  If mFragment.IsGooglePlayServicesAvailable = False Then
  ToastMessageShow("Google Play services not available.", True)
  Else
  mFragment.Initialize("Map", MapPanel)
  End If
End Sub
Sub Map_Ready
  Log("map ready")
  gmap = mFragment.GetMap
  If gmap.IsInitialized = False Then
  ToastMessageShow("Error initializing map.", True)
  Else
  gmap.AddMarker3(36, 15, "Hello!!!", LoadBitmap(File.DirAssets, "smiley.png"))
  Dim cp As CameraPosition
  cp.Initialize(36, 15, gmap.CameraPosition.Zoom)
  gmap.AnimateCamera(cp)
  End If
End Sub
 
Upvote 0

Dario126

Member
Licensed User
Longtime User
Well, last piece of code in previous email was wrong because I was assigning null instead of actual bitmap for icon. It works ok if I insert LoadBitmap as Your example. However, that method gives me icon with no adjusted size for map (no scaling). So I must use Google Extras to load icon and size it properly.

But this method still thus not work in rapid debug. Here is full example of that code.

B4X:
Dim IconFileName As String = "marker car.png"
Dim mo As MarkerOptions
mo.Initialize
mo.Title("sTitle")
mo.Snippet("sDesc")
mo.Position2(iHotSpot.Lat, iHotSpot.Lon)
Dim BD As BitmapDescriptorFactory
mo.Icon(BD.FromAsset(IconFileName))

Dim tmpMarker As Marker
tmpMarker=gXtra.AddMarker(gMap, mo)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Maybe the file should better renamed from marker car.png to marker_car.png or markercar.png? I dont know whether a space in the name matters or not... Normally it is better to use "webserverfriendly" names.
 
Upvote 0

Dario126

Member
Licensed User
Longtime User
Erel, your diagnose looks to be correct. #DebuggerForceStandardAssets has solved original problem. However I hope you can fix it to be more intuitive in future versions ..

And why you think LoadBitmap is better than BitmapDescriptorFactory? Because it is more "standard"?
Maybe, but with LoadBitmap I do not get scaled picture on maps marker, but only part of it if original file is too big ..
 
Upvote 0
Top