MapLineLayer class

A sublayer which renders group of MapLine on MapShapeLayer and MapTileLayer.

  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;
}

See also:

Inheritance

Constructors

MapLineLayer({Key? key, required Set<MapLine> lines, Animation<double>? animation, Color? color, double width = 2, StrokeCap strokeCap = StrokeCap.butt, List<double> dashArray = const <double>[0, 0], IndexedWidgetBuilder? tooltipBuilder})
Creates the MapLineLayer.
const

Properties

animation Animation<double>?
Animation for the lines in MapLineLayer.
final
color Color?
The color of all the lines.
final
dashArray List<double>
Apply same dash pattern for all the MapLine in the lines collection.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
lines Set<MapLine>
A collection of MapLine.
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 all lines. 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
tooltipBuilder IndexedWidgetBuilder?
Returns a widget for the map line tooltip based on the index.
finalinherited
width double
The width of all the lines.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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}) 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 short, textual description of this widget.
inherited

Operators

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