Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
- ignore positioned_tap_detector_2
- ignore MapPosition
  • Loading branch information
josxha committed Jan 13, 2024
1 parent d97b781 commit b1b5544
Show file tree
Hide file tree
Showing 24 changed files with 292 additions and 45 deletions.
2 changes: 2 additions & 0 deletions lib/src/gestures/interactive_flag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
abstract class InteractiveFlag {
const InteractiveFlag._();

/// All available interactive flags, use as `flags: InteractiveFlag.all` to
/// enable all gestures.
static const int all = drag |
flingAnimation |
pinchMove |
Expand Down
71 changes: 71 additions & 0 deletions lib/src/gestures/map_events.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,71 @@
import 'package:flutter/animation.dart';
import 'package:flutter_map/src/map/camera/camera.dart';
import 'package:latlong2/latlong.dart';
import 'package:meta/meta.dart';

/// Event sources which are used to identify different types of
/// [MapEvent] events
enum MapEventSource {
/// The [MapEvent] is caused programmatically by the [MapController].
mapController,

/// The [MapEvent] is caused by a tap gesture.
tap,

/// The [MapEvent] is caused by a secondary tap gesture.
secondaryTap,

/// The [MapEvent] is caused by a long press gesture.
longPress,

/// The [MapEvent] is caused by a double tap gesture.
doubleTap,

/// The [MapEvent] is caused by a double tap and hold gesture.
doubleTapHold,

/// The [MapEvent] is caused by the start of a drag gesture.
dragStart,

/// The [MapEvent] is caused by a drag update gesture.
onDrag,

/// The [MapEvent] is caused by the end of a drag gesture.
dragEnd,

/// The [MapEvent] is caused by the start of a two finger gesture.
multiFingerGestureStart,

/// The [MapEvent] is caused by a two finger gesture update.
onMultiFinger,

/// The [MapEvent] is caused by a the end of a two finger gesture.
multiFingerEnd,

/// The [MapEvent] is caused by the [AnimationController] while performing
/// the fling gesture.
flingAnimationController,

/// The [MapEvent] is caused by the [AnimationController] while performing
/// the double tap zoom in animation.
doubleTapZoomAnimationController,

/// The [MapEvent] is caused by a change of the interactive flags.
interactiveFlagsChanged,

/// The [MapEvent] is caused by calling fitCamera.
fitCamera,

/// The [MapEvent] is caused by a custom source.
custom,

/// The [MapEvent] is caused by a scroll wheel zoom gesture.
scrollWheel,

/// The [MapEvent] is caused by a size change of the [FlutterMap] constraints.
nonRotatedSizeChange,

/// The [MapEvent] is caused by a CTRL + drag rotation gesture.
cursorKeyboardRotation,
}

Expand All @@ -38,6 +80,8 @@ abstract class MapEvent {
/// The map camera after the event.
final MapCamera camera;

/// Base constructor for [MapEvent] that gets overridden by its extended
/// classes.
const MapEvent({
required this.source,
required this.camera,
Expand All @@ -49,8 +93,10 @@ abstract class MapEvent {
/// which are not partial (e.g start rotate, rotate, end rotate).
@immutable
abstract class MapEventWithMove extends MapEvent {
/// The [MapCamera] before the map move event occurred.
final MapCamera oldCamera;

/// Create a new map event that represents a movement event
const MapEventWithMove({
required super.source,
required this.oldCamera,
Expand Down Expand Up @@ -103,18 +149,21 @@ class MapEventTap extends MapEvent {
/// Point coordinates where user has tapped
final LatLng tapPosition;

/// Create a new map event that represents a tap on the map
const MapEventTap({
required this.tapPosition,
required super.source,
required super.camera,
});
}

/// Event which is fired when map is secondary tapped
@immutable
class MapEventSecondaryTap extends MapEvent {
/// Point coordinates where user has tapped
final LatLng tapPosition;

/// Create a new map event that represents a secondary tap on the map
const MapEventSecondaryTap({
required this.tapPosition,
required super.source,
Expand All @@ -128,6 +177,7 @@ class MapEventLongPress extends MapEvent {
/// Point coordinates where user has long-pressed
final LatLng tapPosition;

/// Create a new map event that represents a long press on the map
const MapEventLongPress({
required this.tapPosition,
required super.source,
Expand All @@ -141,6 +191,7 @@ class MapEventMove extends MapEventWithMove {
/// Custom ID to identify related object(s)
final String? id;

/// Create a new map event that represents a map movement
const MapEventMove({
this.id,
required super.source,
Expand All @@ -152,6 +203,7 @@ class MapEventMove extends MapEventWithMove {
/// Event which is fired when dragging is started
@immutable
class MapEventMoveStart extends MapEvent {
/// Create a new map event that represents the start of a drag event
const MapEventMoveStart({
required super.source,
required super.camera,
Expand All @@ -161,6 +213,7 @@ class MapEventMoveStart extends MapEvent {
/// Event which is fired when dragging is finished
@immutable
class MapEventMoveEnd extends MapEvent {
/// Create a new map event that represents the end of a drag event
const MapEventMoveEnd({
required super.source,
required super.camera,
Expand All @@ -170,6 +223,7 @@ class MapEventMoveEnd extends MapEvent {
/// Event which is fired when animation started by fling gesture is in progress
@immutable
class MapEventFlingAnimation extends MapEventWithMove {
/// Create a new map event that represents an ongoing fling animation
const MapEventFlingAnimation({
required super.source,
required super.oldCamera,
Expand All @@ -181,6 +235,8 @@ class MapEventFlingAnimation extends MapEventWithMove {
/// to start fling animation
@immutable
class MapEventFlingAnimationNotStarted extends MapEvent {
/// Create a new map event that for when the performed fling gesture had
/// not enough velocity to cause a fling animation.
const MapEventFlingAnimationNotStarted({
required super.source,
required super.camera,
Expand All @@ -190,6 +246,7 @@ class MapEventFlingAnimationNotStarted extends MapEvent {
/// Event which is fired when fling gesture is detected
@immutable
class MapEventFlingAnimationStart extends MapEvent {
/// Create a new map event that represents the start of a fling animation
const MapEventFlingAnimationStart({
required super.source,
required super.camera,
Expand All @@ -199,6 +256,7 @@ class MapEventFlingAnimationStart extends MapEvent {
/// Event which is fired when animation started by fling gesture finished
@immutable
class MapEventFlingAnimationEnd extends MapEvent {
/// Create a new map event that represents the end of a fling animation
const MapEventFlingAnimationEnd({
required super.source,
required super.camera,
Expand All @@ -208,6 +266,7 @@ class MapEventFlingAnimationEnd extends MapEvent {
/// Event which is fired when map is double tapped
@immutable
class MapEventDoubleTapZoom extends MapEventWithMove {
/// Create a new map event that represents an ongoing double tap zoom gesture.
const MapEventDoubleTapZoom({
required super.source,
required super.oldCamera,
Expand All @@ -218,6 +277,8 @@ class MapEventDoubleTapZoom extends MapEventWithMove {
/// Event which is fired when scroll wheel is used to zoom
@immutable
class MapEventScrollWheelZoom extends MapEventWithMove {
/// Create a new map event that represents an ongoing scroll wheel
/// zoom gesture.
const MapEventScrollWheelZoom({
required super.source,
required super.oldCamera,
Expand All @@ -228,6 +289,8 @@ class MapEventScrollWheelZoom extends MapEventWithMove {
/// Event which is fired when animation for double tap gesture is started
@immutable
class MapEventDoubleTapZoomStart extends MapEvent {
/// Create a new map event that represents the start of a double tap
/// zoom gesture.
const MapEventDoubleTapZoomStart({
required super.source,
required super.camera,
Expand All @@ -237,6 +300,8 @@ class MapEventDoubleTapZoomStart extends MapEvent {
/// Event which is fired when animation for double tap gesture ends
@immutable
class MapEventDoubleTapZoomEnd extends MapEvent {
/// Create a new map event that represents the end of a double tap
/// zoom gesture.
const MapEventDoubleTapZoomEnd({
required super.source,
required super.camera,
Expand All @@ -249,6 +314,7 @@ class MapEventRotate extends MapEventWithMove {
/// Custom ID to identify related object(s)
final String? id;

/// Create a new map event that represents an ongoing map rotation.
const MapEventRotate({
required this.id,
required super.source,
Expand All @@ -260,6 +326,7 @@ class MapEventRotate extends MapEventWithMove {
/// Event which is fired when rotate gesture was started
@immutable
class MapEventRotateStart extends MapEvent {
/// Create a new map event that represents the start of a map rotation.
const MapEventRotateStart({
required super.source,
required super.camera,
Expand All @@ -269,14 +336,18 @@ class MapEventRotateStart extends MapEvent {
/// Event which is fired when rotate gesture has ended
@immutable
class MapEventRotateEnd extends MapEvent {
/// Create a new map event that represents the end of a map rotation.
const MapEventRotateEnd({
required super.source,
required super.camera,
});
}

/// Event that fires when the map widget changes size, e.g. when the app window
/// gets changed in size.
@immutable
class MapEventNonRotatedSizeChange extends MapEventWithMove {
/// Create a new map event that represents that the widget size has changed.
const MapEventNonRotatedSizeChange({
required super.source,
required super.oldCamera,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/gestures/map_interactive_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ class MapInteractiveViewerState extends State<MapInteractiveViewer>
}
}

///
void _startListeningForAnimationInterruptions() {
_isListeningForInterruptions = true;
}
Expand All @@ -903,6 +904,7 @@ class MapInteractiveViewerState extends State<MapInteractiveViewer>
_isListeningForInterruptions = false;
}

/// Cancel every ongoing animated map movements.
void interruptAnimatedMovement(MapEvent event) {
if (_isListeningForInterruptions) {
_closeDoubleTapController(event.source);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/gestures/positioned_tap_detector_2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// /// https://github.com/arsamme/flutter-positioned-tap-detector ///
// //////////////////////////////////////////////////////////////////

// ignore_for_file: public_member_api_docs

import 'dart:async';
import 'dart:math';

Expand Down
21 changes: 18 additions & 3 deletions lib/src/layer/circle_layer.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
import 'dart:ui';

import 'package:flutter/widgets.dart';
import 'package:flutter_map/src/layer/general/mobile_layer_transformer.dart';
import 'package:flutter_map/src/map/camera/camera.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart' hide Path;

/// Immutable marker options for circle markers
/// Immutable marker options for [CircleMarker]. Circle markers are a more
/// simple and performant way to draw markers as the regular [Marker]
@immutable
class CircleMarker {
final Key? key;

/// The center coordinates of the circle
final LatLng point;

/// The radius of the circle
final double radius;

/// The color of the circle area.
final Color color;

/// The stroke width for the circle border. Defaults to 0 (no border)
final double borderStrokeWidth;

/// The color of the circle border line. Needs [borderStrokeWidth] to be > 0
/// to be visible.
final Color borderColor;
final bool useRadiusInMeter;

/// Constructor to create a new [CircleMarker] object
const CircleMarker({
required this.point,
required this.radius,
Expand All @@ -27,10 +39,13 @@ class CircleMarker {
});
}

/// A layer that displays a list of [CircleMarker] on the map
@immutable
class CircleLayer extends StatelessWidget {
/// The list of [CircleMarker]s.
final List<CircleMarker> circles;

/// Create a new [CircleLayer] as a child for flutter map
const CircleLayer({super.key, required this.circles});

@override
Expand Down
Loading

0 comments on commit b1b5544

Please sign in to comment.