buildLayer method

  1. @override
Widget buildLayer(
  1. BuildContext context,
  2. MapState map
)
override

override this function for every map layers

Implementation

@override
Widget buildLayer(BuildContext context, MapState map) {
  final pixelOrigin = map.pixelOrigin;
  final scale = map.getZoomScale(map.zoom, map.zoom);
  final nw = map.project(bounds.northWest);
  final se = map.project(bounds.southEast);

  final topLeft = (nw * scale) - pixelOrigin;
  final bottomRight = (se * scale) - pixelOrigin;

  final double top = topLeft.y;
  final double left = topLeft.x;
  final width = bottomRight.x - topLeft.x;
  final height = bottomRight.y - topLeft.y;
  final opacity = this.opacity ?? 1.0;

  return Positioned(
    top: top,
    left: left,
    width: width,
    height: height,
    child: InteractiveGestureDetector(
      position: bounds,
      data: data,
      options: options,
      child: Opacity(
        opacity: opacity,
        child: child,
      ),
    ),
  );
}