Android Question Problems with markers on Google Maps

bgsoft

Well-Known Member
Licensed User
Longtime User
Hello

I've placed this code in several applications that work perfectly.

B4X:
         Dim MarkerOptions1 As MarkerOptions
         MarkerOptions1.Initialize
             
         Dim BitmapDescriptor1 As BitmapDescriptor
         Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
         BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset(IconoMapas)
      
         MarkerOptions1.Icon(BitmapDescriptor1)      
         MarkerOptions1.Position2(41.38640,1.931530)
       
         MarkerOptions1.Title("1")
         MarkerOptions1.Visible(True)
         Dim MyMarker As Marker
         GoogleMapsExtras1.AddMarker(GoogMaps, MarkerOptions1)  ' <- Here gives the error
         MyMarker.InfoWindowShown = True ' open label

When I went to change another part of the code, compiling and re-enter this code gives me this error:

java.lang.NullPointerException
at com.google.k.a.cj.a(Unknown Source)
at com.google.maps.api.android.lib6.c.dc.(Unknown Source)
at com.google.maps.api.android.lib6.c.db.a(Unknown Source)
at com.google.maps.api.android.lib6.c.aj.(Unknown Source)
at com.google.maps.api.android.lib6.c.al.a(Unknown Source)
at com.google.maps.api.android.lib6.c.el.a(Unknown Source)
at com.google.android.gms.maps.internal.l.onTransact(SourceFile:167)
at android.os.Binder.transact(Binder.java:361)
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)
at bgs.maps.main._mapalib(main.java:834)
at bgs.maps.main._map_ready(main.java:782)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.MapFragmentWrapper$MyMapFragment.onViewCreated(MapFragmentWrapper.java:191)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:904)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1453)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException



Although change and put this code, does not work.
B4X:
  Dim Marker1 As Marker=GoogleMapsExtras1.AddMarker(GoogleMap1, MarkerOptions1)



Samsung Galaxy 4 (Android 4.4.2): the icon appears, the label does not appear.
Samsung Galaxy Tab 4 (Android 4.4.2): not the icon or label appears.
LG Optimus G (Android 4.4.2): not the icon or label appears.

If I put a Try Catch for not selling out error, it gives me the error but not the label appears.

capture1.jpg

Placing the mouse over, get this message, but the Marker does not have this method

In the Samsung Galaxy 4 gives this error:
java.lang.RuntimeException: Object should first be initialized (Marker).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
at anywheresoftware.b4a.objects.MapFragmentWrapper$MarkerWrapper.setInfoWindowShown(MapFragmentWrapper.java:448)


The SDK's I have updated to today.

regards
 
Last edited:

ronnhdf

Member
Licensed User
Longtime User
Ich habe das gleiche Problem

B4X:
Log("MapFragment1_Ready")
  GoogleMap1 = MapFragment1.GetMap
  If GoogleMap1.IsInitialized = False Then
  ToastMessageShow("Error initializing map.", True)
  Else
     '   use the new MarkerOptions method to create and add a Marker to the map

     Dim MarkerOptions1 As MarkerOptions
     MarkerOptions1.Initialize

     MarkerOptions1.Position2(52.75619, 0.3980).Snippet("Home is where the heart is").Title("Home Sweet Home").Visible(True)

     Dim BitmapDescriptor1 As BitmapDescriptor
     Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory

     BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("person.png") <--- Fehler
    BitmapDescriptor1=BitmapDescriptorFactory1.FromBitmap(LoadBitmap(File.DirAssets, "person.png")) <--- geht aber Marker ist nur ein Teil zu sehen

     MarkerOptions1.Icon(BitmapDescriptor1)

     Dim Marker1 As Marker=GoogleMapsExtras1.AddMarker(GoogleMap1, MarkerOptions1)

  Dim CameraPosition1 As CameraPosition
  CameraPosition1.Initialize(52.75619, 0.3980, 6)
  GoogleMap1.AnimateCamera(CameraPosition1)
  End If



BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("person.png") <--- Fehler

BitmapDescriptor1=BitmapDescriptorFactory1.FromBitmap(LoadBitmap(File.DirAssets, "person.png")) <--- geht aber Marker ist nur ein Teil zu sehen
 
Upvote 0
Top