Android Question Google maps problem

Duncan H Williamson

Member
Licensed User
Longtime User
Hi All
I have built a little app using googlemaps and googlemapextra, the code below is used in mfragment_ready.
I am retrieving lat lng data for a polygon from a database and loading it into points in a seperate sub.
The app loads a start page and then loads via a menu a seperate page from an activity module.
It works perfectly when first run, bringing up the page with the mapfragment showing the polygon, however if I return to the main page and then go back to the map page the app crashes with the message " unfortunately app has stopped". If I add the points via code in the mfragment_ready then it works perfectly and I can go back and forth without issue....
I changed the sub which pulls data from the database and coded the points data, Identical to putting it in the mfragment_ready sub and it performed exactly as when data was pulled from the database ie it crashed on returning.. Any help or suggestions would be greatly appreciated

Regards
Duncan

B4X:
gmap = mFragment.GetMap
   If gmap.IsInitialized = False Then
      ToastMessageShow("Error initializing map.", True)
   Else
       gmap.MapType = gmap.MAP_TYPE_HYBRID
    Dim GoogleMapsExtras1 As GoogleMapsExtras
    Dim PolygonOptions1 As PolygonOptions
     
     Dim CircleOptions1 As CircleOptions
      CircleOptions1.Initialize
     PolygonOptions1.Initialize
     PolygonOptions1.FillColor=Colors.ARGB(50, 47, 222, 249)
      PolygonOptions1.AddPoints(Points)
      PolygonOptions1.StrokeColor=Colors.Black
      PolygonOptions1.StrokeWidth=1
     
      Polygon1=GoogleMapsExtras1.AddPolygon(gmap, PolygonOptions1)    
      Dim cp As CameraPosition
      cp.Initialize(-37.9658, 176.989, 8)
      gmap.AnimateCamera(cp)
     
       mFragment.GetMap.MyLocationEnabled = True
      Dim OnMyLocationChangeListener1 As OnMyLocationChangeListener
        OnMyLocationChangeListener1.Initialize("OnMyLocationChangeListener1")
        GoogleMapsExtras1.SetOnMyLocationChangeListener(gmap, OnMyLocationChangeListener1)    
   End If
 
Top