eventShowLocation function

Widget eventShowLocation(
  1. List<HybridModel> users,
  2. LatLng venue
)

Implementation

Widget eventShowLocation(List<HybridModel> users, LatLng venue) {
  print('FlutterMap called');
  var _popupController = PopupController();
  var mapController = MapController();
  var markers = users.map((user) => user.marker).toList();
  print('markers length = ${markers.length}');
  users.forEach((element) {
    print('displayanme - ${element.displayName}');
  });
  markers.forEach((element) {
    print('point - ${element!.point}');
  });

  var _eventData = users[users.indexWhere((e) => e.latLng == venue)];

  return Stack(
    children: [
      FlutterMap(
        key: UniqueKey(),
        mapController: mapController,
        options: MapOptions(
          center: venue,
          zoom: markers.isNotEmpty ? 8 : 2,
          plugins: [MarkerClusterPlugin(UniqueKey())],
          onTap: (_) => _popupController.hidePopup(),
        ),
        layers: [
          TileLayerOptions(
            minNativeZoom: 2,
            maxNativeZoom: 18,
            minZoom: 2,
            urlTemplate:
                'https://api.maptiler.com/maps/streets/{z}/{x}/{y}.png?key=${MixedConstants.MAP_KEY}',
          ),
          MarkerClusterLayerOptions(
            maxClusterRadius: 190,
            disableClusteringAtZoom: 16,
            size: Size(200, 150),
            anchor: AnchorPos.align(AnchorAlign.center),
            fitBoundsOptions: FitBoundsOptions(
              padding: EdgeInsets.all(50),
            ),
            markers: markers,
            polygonOptions: PolygonOptions(
                borderColor: Colors.blueAccent,
                color: Colors.black12,
                borderStrokeWidth: 3),
            popupOptions: PopupOptions(
                popupSnap: PopupSnap.top,
                popupController: _popupController,
                popupBuilder: (_, marker) {
                  return _popupController.streamController!.isClosed
                      ? Text('Closed')
                      : buildPopup(users[markers.indexOf(marker)],
                          center: venue);
                }),
            builder: (context, markers) {
              return buildMarkerCluster(markers, eventData: _eventData);
            },
          ),
        ],
      ),
      Positioned(
        top: 100,
        right: 0,
        child: FloatingIcon(
            icon: Icons.zoom_out_map,
            onPressed: () {
              _popupController.hidePopup();
              mapController.move(venue, 4);
            }),
      ),
    ],
  );
}