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

How do I disable mocked location? #67

Closed canismayorisxl closed 1 year ago

canismayorisxl commented 1 year ago

Hello the title is my question :-)

canismayorisxl commented 1 year ago

Quick reply, I added a piece of code that allows for disabling location mocking. It looks as followed.

in current_location_layer.dart add final bool? disableMocking; // add this.disableMocking in the constructor. // change the location stream to positionStream = positionStream ?? const LocationMarkerDataStreamFactory() .fromGeolocatorPositionStream( disabledMockedLocation: disableMocking ?? false)

In data_stream_factory change the function to this: Stream<LocationMarkerPosition?> fromGeolocatorPositionStream({ Stream<Position?>? stream, bool disabledMockedLocation = false, }) { return (stream ?? defaultPositionStreamSource()).map((Position? position) { return position != null && (disabledMockedLocation && !position.isMocked) ? LocationMarkerPosition( latitude: position.latitude, longitude: position.longitude, accuracy: position.accuracy, ) : null; }); }

github-actions[bot] commented 1 year 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.

tlserver commented 1 year ago

As you said this requirement can be fulfilled by providing a filtered position stream. Not planed to change the library.