MarkerAnnotation.fromJsonMap constructor
Creates a MarkerAnnotation from a JSON map.
This factory method is used during workflow deserialization to recreate marker annotations from saved data.
Implementation
factory MarkerAnnotation.fromJsonMap(Map<String, dynamic> json) {
final markerTypeName = json['markerType'] as String? ?? 'info';
final markerType = MarkerType.values.firstWhere(
(e) => e.name == markerTypeName,
orElse: () => MarkerType.info,
);
final annotation = MarkerAnnotation(
id: json['id'] as String,
position: Offset(
(json['x'] as num).toDouble(),
(json['y'] as num).toDouble(),
),
markerType: markerType,
markerSize: (json['markerSize'] as num?)?.toDouble() ?? 24.0,
color: Color(json['color'] as int? ?? Colors.red.toARGB32()),
tooltip: json['tooltip'] as String?,
zIndex: json['zIndex'] as int? ?? 0,
isVisible: json['isVisible'] as bool? ?? true,
isInteractive: json['isInteractive'] as bool? ?? true,
dependencies:
(json['dependencies'] as List?)?.cast<String>().toSet() ?? {},
metadata: json['metadata'] as Map<String, dynamic>? ?? {},
);
return annotation;
}