MapLine class

Creates a line between the two geographical coordinates on the map.

  late List<Model> _lines;
  late MapZoomPanBehavior _zoomPanBehavior;
  late MapShapeSource _mapSource;

  @override
  void initState() {
    _zoomPanBehavior = MapZoomPanBehavior(
      focalLatLng: MapLatLng(40.7128, -95.3698),
      zoomLevel: 3,
    );

    _mapSource = MapShapeSource.asset(
      "assets/world_map.json",
      shapeDataField: "continent",
    );

    _lines = <Model>[
      Model(MapLatLng(40.7128, -74.0060), MapLatLng(44.9778, -93.2650)),
      Model(MapLatLng(40.7128, -74.0060), MapLatLng(33.4484, -112.0740)),
      Model(MapLatLng(40.7128, -74.0060), MapLatLng(29.7604, -95.3698)),
      Model(MapLatLng(40.7128, -74.0060), MapLatLng(39.7392, -104.9903)),
    ];

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfMaps(
        layers: [
          MapShapeLayer(
            source: _mapSource,
            zoomPanBehavior: _zoomPanBehavior,
            sublayers: [
              MapLineLayer(
                lines: List<MapLine>.generate(
                  _lines.length,
                  (int index) {
                    return MapLine(
                      from: _lines[index].from,
                      to: _lines[index].to,
                    );
                  },
                ).toSet(),
              ),
            ],
          ),
        ],
      ),
    );
  }

class Model {
  Model(this.from, this.to);

  MapLatLng from;
  MapLatLng to;
}
Inheritance

Constructors

MapLine({required MapLatLng from, required MapLatLng to, List<double>? dashArray, Color? color, double? width, StrokeCap? strokeCap, VoidCallback? onTap})
Creates a MapLine.
const

Properties

color Color?
Color of the line.
final
dashArray List<double>?
Apply dash pattern for the line.
final
from MapLatLng
The starting coordinate of the line.
final
hashCode int
The hash code for this object.
no setterinherited
onTap VoidCallback?
Callback to receive tap event for this line.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
strokeCap StrokeCap?
Applies stroke cap to the start and end of the line. You can set StrokeCap.round to get a semi-circle or StrokeCap.square to get a semi-square at the edges of the line.
final
to MapLatLng
The ending coordinate of the line.
final
width double?
Width of the line.
final

Methods

debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited