tlserver / flutter_map_location_marker

A flutter map plugin for displaying device current location.
https://pub.dev/packages/flutter_map_location_marker
BSD 3-Clause "New" or "Revised" License
97 stars 81 forks source link

Layer causes constant "Please enable gps" dialog if user has disabled their gps #29

Closed MTRNord closed 2 years ago

MTRNord commented 2 years ago

Hi I have

LocationMarkerLayerOptions(
    marker: DefaultLocationMarker(
        color: Color(0xFFDE9D1D).withOpacity(0.5),
    ),
    accuracyCircleColor: Color(0xFFDFD772).withOpacity(0.5),
    headingSectorColor: Color(0xFFDFD772).withOpacity(0.5),
),

in my layers.

If my phone has gps disabled this layer causes thousands of "please enable gps" popus to show up. Removing the layer fixes this.

Any idea why this may happen?

https://user-images.githubusercontent.com/1374914/170100135-e0d13f50-860c-4891-87e3-a069e0c26182.mp4

tlserver commented 2 years ago

Duplicate of #26

tlserver commented 2 years ago

Sorry, I cannot reproduce this issue. How do you build the map? And what API level of android are you using?

I have tested the following code in API 28 and API30, only one dialog pop up.

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
import 'package:latlong2/latlong.dart';

class OldStyleExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Old Style Example'),
      ),
      body: FlutterMap(
        options: MapOptions(
          center: LatLng(0, 0),
          zoom: 1,
          maxZoom: 19,
          plugins: [
            const LocationMarkerPlugin(),
          ],
        ),
        layers: [
          TileLayerOptions(
            urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            subdomains: ['a', 'b', 'c'],
            maxZoom: 19,
          ),
          LocationMarkerLayerOptions(
            marker: DefaultLocationMarker(
              color: const Color(0xFFDE9D1D).withOpacity(0.5),
            ),
            accuracyCircleColor: const Color(0xFFDFD772).withOpacity(0.5),
            headingSectorColor: const Color(0xFFDFD772).withOpacity(0.5),
          ),
        ],
      ),
    );
  }
}

Are you re-building the FlutterMap each frame? For there is some internal data stored in the marker layer, it may cause this kind of problem if you re-build it each frame.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 2 years ago

This issue was closed because it has been stalled for 7 days with no activity.