Android Question MapFragment problem ?

Borgamiga

New Member
Licensed User
Longtime User
Hello.
I have a problem.
The next iteration of the MapFragment _Ready procedure is getting slower,
until a Stack Overflow error occurs or another device out of memory. (9-10 iteration). Am I doing something wrong? In the actual program, the data for the map I download from the excel sheet. (Approximately 2000 points maximum). In the sample is 10000 to highlight the problem. I was trying to optimize the program.
The gmap.clear statement does not work, it looks like MapFragment did not release memory.

B4X:
#Region  Project Attributes
   #ApplicationLabel: B4A Example
   #VersionCode: 1
   #VersionName:
   'SupportedOrientations possible values: unspecified, landscape or portrait.
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: False
   #AdditionalJar: com.google.android.gms:play-services-maps
#End Region

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

'Activity module
Sub Process_Globals
    Dim czas_old  As Long
    Dim czas As Long
End Sub

Sub Globals
    Private gmap As GoogleMap
    Private MapFragment1 As MapFragment
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("2")
    If MapFragment1.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("Please install Google Play Services.", True)
    End If
End Sub

Sub MapFragment1_Ready
    gmap = MapFragment1.GetMap
    czas_old = DateTime.Now
    For i=0 To 10000
        gmap.AddMarker(Rnd(30,45),Rnd(30,45),("marker"&i))
    Next
    czas=DateTime.Now-czas_old
    Log (czas)
End Sub

Sub RETURN_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("2")
End Sub

Sub START_Click
    Activity.RemoveAllViews
    Activity.LoadLayout("1")
End Sub

Regards
 

Borgamiga

New Member
Licensed User
Longtime User
Hey.
My program is used to search and display parts of a vast network of points, which can be navigated through googlemaps intent or display the necessary information.Therefore, in a dozen or so minutes I have to display
The layout of the map and the layout of the map in a moment. When I want to change the search criteria, I again display the search engine layout or some other layout and back to the map layout. I do this by "Activity.LoadLayouts (" layout ")" and then "Activity.RemoveAllViews" And here I noticed the problem described. On a slow loading device the markers take a few seconds. Should I
use a more elaborate layout with multiple values and use the parameter "visible = true or false"? i thought my original way of releasing resources and would be most responsive (do not waste time deleting previous markers from the map) .and maybe i do not know some basic technique of using Layouts
 
Upvote 0

Borgamiga

New Member
Licensed User
Longtime User
Hi
Just creating a map on the test device takes 4 seconds, loading 10000 points for 3 seconds and you do not see the effect of "fatigue", so re-use the map can bring measurable benefits already with the second iteration with the map, only since links to Mapfragment lead from several Layouts then I would have to hide Mapfragment on any Layouts ie I would have to use a few Mapfragment which is probably going to miss the goal and may deepen the problem with the first question of this thread. And still bother me the theoretical question why multiple map creation causes a problem?
Apparently there are no stupid questions
 
Upvote 0

Borgamiga

New Member
Licensed User
Longtime User
Hey I do not like what I like, I like what I have. I try to rewrite the application to get rid of this inconvenience. Thanks.
Machine translation.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…