addMarkerPoint method
Future<void>
addMarkerPoint(
- String markerId,
- String markerImage,
- List<
Map< data, {String, dynamic> > - int animationDuration = 50,
- double scale = 15,
- Map<
String, dynamic> properties = const {"icon-opacity" : 1.0, "icon-size" : 1.0, "icon-anchor" : "center", "icon-offset" : [0.5, 0.5], 'icon-allow-overlap' : true, 'icon-ignore-placement' : true}, - Curve positionCurve = Curves.linear,
- Curve rotationCurve = Curves.linear,
Adds a marker marker to the map and animates it between points.
markerId: A unique identifier for the marker.markerImage: The path to the image file to be used as the marker icon.data: A list of position and rotation data for the marker animation {position:double, double, rotation: double}[].properties: (Optional) Custom properties for marker style.scale: (optional) A scale factor for the image.animationDuration: (optional) How long the animation should last.positionCurve: (optional) Custom curve for position animations.rotationCurve: (optional) Custom curve for rotation animations.
Implementation
Future<void> addMarkerPoint(
String markerId,
String markerImage,
List<Map<String, dynamic>> data, {
int animationDuration = 50,
double scale = 15,
Map<String, dynamic> properties = const {
"icon-opacity": 1.0,
"icon-size": 1.0,
"icon-anchor": "center",
"icon-offset": [0.5, 0.5],
'icon-allow-overlap': true,
'icon-ignore-placement': true,
},
Curve positionCurve = Curves.linear,
Curve rotationCurve = Curves.linear,
}) async {
try {
// Store marker points (positions and rotations).
markerPoints.putIfAbsent(markerId, () => []);
for (var data in data) {
Point newPoint = Point(
coordinates: Position(data['position'][0], data['position'][1]));
num rotation = data['rotation'];
markerPoints[markerId]?.add({'point': newPoint, 'rotation': rotation});
}
// Initialize the marker stream if it doesn't exist.
if (!_locationStreamControllers.containsKey(markerId) &&
markerPoints[markerId]!.length > 2) {
await _initializeMarkerStreams(
markerId: markerId,
markerImage: markerImage,
properties: properties,
scale: scale,
animationDuration: animationDuration,
positionCurve: positionCurve,
rotationCurve: rotationCurve,
);
}
// Trigger the stream to start the animation.
_locationStreamControllers[markerId]?.add("animate");
} on Exception catch (_) {
rethrow;
}
}