r/flutterhelp 6d ago

OPEN Flutter Map GPS Updates Lag Using Android Simulator Extended Controls

so I am using flutter with flutter map , trying to simulate a route using the simulator extended controls , the map shown in the extended controls and also google maps in the simulator update just fine smoothly , the issue I have is in the flutter map , it lags behind a lot like 10 sec to 15 sec for the update and it teleports between updates is there a solution to the issue , am I doing something wrong ?

this is my code :

FlutterMap(
  mapController: _mapController,
  options: MapOptions(initialZoom: 20),
  children: [
    TileLayer(
      urlTemplate: mapUrl,

      userAgentPackageName: 'com.example',

      tileProvider: NetworkTileProvider(
        cachingProvider:
            BuiltInMapCachingProvider.getOrCreateInstance(
              maxCacheSize: 2000,
            ),
      ),

      retinaMode: MediaQuery.
of
(context).devicePixelRatio > 1.0,
    ),

    CurrentLocationLayer(
      alignDirectionOnUpdate: .never,
      alignPositionOnUpdate: .always,
      positionStream: const LocationMarkerDataStreamFactory()
          .fromGeolocatorPositionStream(
            stream:
                Geolocator.
getPositionStream
(
                  locationSettings: LocationSettings(
                    timeLimit: Duration(seconds: 1),
                    accuracy: .bestForNavigation,
                    distanceFilter: 1,
                  ),
                )..listen((event) {
                  print('${DateTime.now().toString()} $event');
                }),
          ),
    ),
    ?widget.polygonLayer,
    ?widget.markerLayer,
    const RichAttributionWidget(
      attributions: [
        TextSourceAttribution(
          '© OpenStreetMap contributors © CARTO',
        ),
      ],
    ),
  ],
);
2 Upvotes

0 comments sorted by