buildMarkerLayers method
Implementation
List<Widget> buildMarkerLayers() {
final List<Marker> normalMarkers = [];
AnimatedMarkerLayer? animatedMarkerLayer;
for (var m in Markers) {
if (m.heading == null) {
final marker = Marker(
width: m.Width,
height: m.Height,
point: LatLng(m.Positions!.lat, m.Positions!.lng),
alignment: Alignment.center,
rotate: m.heading == null, // only rotate if not animated
child: Builder(
builder: (context) => RotationTransition(
turns: AlwaysStoppedAnimation(m.Bearing ?? 0),
child: InkWell(
onTap: () {
if (m.onTap != null) {
TickerProvider vsync = m.onTap!();
_animatedMapMove(
destLocation:
CoordinateRF(m.Positions!.lat, m.Positions!.lng),
destZoom: 14,
vsync: vsync,
);
}
},
child: Image.asset(
m.Image,
height: m.Height,
width: m.Width,
),
),
),
));
normalMarkers.add(marker);
} else {
animatedMarkerLayer = AnimatedMarkerLayer(
options: AnimatedMarkerLayerOptions(
duration: Duration(milliseconds: m.Duration!),
marker: Marker(
width: m.Width,
height: m.Height,
alignment: Alignment.center,
point: LatLng(
m.Positions!.lat,
m.Positions!.lng,
),
child: Center(
child: Transform.rotate(
angle: max(0, m.heading!) * pi / 180,
child: Image.asset(
m.Image,
width: 30,
height: 30,
),
),
),
),
),
);
}
}
return [
if (normalMarkers.isNotEmpty) MarkerLayer(markers: normalMarkers),
animatedMarkerLayer ?? const SizedBox()
];
}