My app takes a long time to respond

I have this component and it works fine, but sometimes especially when the internet is slow, my application does not respond or takes a long time to respond while the map is not fully reloaded. What would be a solution?

I'll be more specific. I have a map loading and I'm running a Thread and when the Internet gets slow the map does not load and my app gets stuck until the map loads completely. Any tips?

Best regards

Hi,


Please note that a reliable internet connection is required for this component.
Unfortunately we have no control over the performance or behavior of the API in situations where the internet connection is slow.
OK thank you! This happens sometimes when I'm creating a route using the component, and sometimes the map does not load and the application freezes.

Question how could I unload the component completely from memory? And try to recharge it again?

Have you tried using the Reinitialize call?

I did not try. I will explain better, I have a form that I pass the latitudes and longitudes to be created a route as below:

TMSFMXWebGMapsMain-> GetDirections (FormMain-> Lat, FormMain-> Lng, FormMain-> LatDst, FormMain-> LngDst,
false, TTravelMode :: tmDriving, TUnits :: usMetric,
TLanguageName :: lnPortuguese);

This is running on a Thread, after it executes this function the thread synchronizes to show the route:

TRoute * Route;
TMarker * MarkerBegin, * MarkerEnd;
Tmswebgmapspolygons :: TMapPolygon * CircleBegin, * CircleEnd;
TPolygonItem * PolygonItem;

Route = TMSFMXWebGMapsMain-> Directions-> operator [] (0);

TMSFMXWebGMapsMain-> MapZoomTo (Route-> Bounds);
TMSFMXWebGMapsMain-> CreateMapPolyline (Route-> Polyline);

MarkerBegin = TMSFMXWebGMapsMain-> Markers-> Add ();
MarkerGenin-> Draggable = false;
MarkerBegin-> Latitude = Route-> Legs-> operator [] (0) -> StartLocation-> Latitude;
MarkerBegin-> Longitude = Route-> Legs-> operator [] (0) -> StartLocation-> Longitude;
        
Marker Home-> Title = L "Iam";
Marker-> Icon = FormMain-> figPointer;
Marker Start-> InitialDropAnimation = true;


MarkerEnd = TMSFMXWebGMapsMain-> Markers-> Add ();
MarkerEnd-> Draggable = false;
MarkerEnd-> Latitude = Route-> Legs-> operator [] (0) -> EndLocation-> Latitude;
MarkerEnd-> Longitude = Route-> Legs-> operator [] (0) -> EndLocation-> Longitude;
MarkerEnd-> InitialDropAnimation = true;

PolygonItem = TMSFMXWebGMapsMain-> Polygons-> Add ();
CircleInicio = PolygonItem-> Polygon;

Circle Start-> PolygonType = ptCircle;
Circle Start-> BackgroundOpacity = 50;
Circle Start-> BorderWidth = 2;
Circle Start-> Radius = Integer (Route-> Legs-> operator [] (0) -> Distance / 30);

if (FormMain-> MyLocalManual) {
Circle Start-> Center-> Latitude = FormMain-> LatitudeManual;
Circle Start-> Center-> Longitude = FormMain-> LongitudeManual;
} else {
Circle Start-> Center-> Latitude = Route-> Legs-> operator [] (0) -> StartLocation-> Latitude;
Circle Start-> Center-> Longitude = Route-> Legs-> operator [] (0) -> StartLocation-> Longitude;
}


PolygonItem = TMSFMXWebGMapsMain-> Polygons-> Add ();
CirculoFim = PolygonItem-> Polygon;

CirculoFim-> PolygonType = ptCircle;
CirculoFim-> BackgroundOpacity = 50;
CircleFim-> BorderWidth = 2;
Circle End-> Radius = Integer (Route-> Legs-> operator [] (0) -> Distance / 30);
Circle-> Center-> Latitude = Route-> Legs-> operator [] (0) -> EndLocation-> Latitude;
Circle-> Center-> Longitude = Route-> Legs-> operator [] (0) -> EndLocation-> Longitude;

TMSFMXWebGMapsMain-> CreateMapPolygon (CircleStart);
TMSFMXWebGMapsMain-> CreateMapPolygon (CircleFim);
TMSFMXWebGMapsMain-> CreateMapMarker (MarkerEnd);
TMSFMXWebGMapsMain-> CreateMapMarker (MarkerStart);

One note is that I only do this after the OnDownloadfinish tells me that the map is fully loaded, so I created a variable that tells me when this happens, only after that I execute the Thread at the beginning of the post.

As I said it usually works most of the time, but sometimes the map does not appear, it looks like it's hidden. When I observed this, I verified in the creation of the form if the masta is visible, if it is not visible I do the following method:

:: FormCreate ...

if (! TMSFMXWebGMapsMain-> Visible) {
TMSFMXWebGMapsMain-> Visible = true;
}

But sometimes it crashes, remembering that I created the method that tells me when the map is fully loaded, except in this case it does not load and my application waits for loading that never happens.

I would like in that case, that when that happens I could empty it of memory and try again.

Another detail I noticed is that this occurs when the Internet is slow.

Best Regards!

The same happens with the Internet of quality

ps: this is happening on Android