toJson method
Converts this polygon to a JSON object for serialization.
This is used to pass polygon data to the HTML map view. Returns a GeoJSON-compatible structure.
Implementation
Map<String, dynamic> toJson() {
return {
'id': id,
'coordinates': coordinates
.map((coord) => {'lat': coord.latitude, 'lng': coord.longitude})
.toList(),
'fillColor': _colorToString(fillColor) ?? '#0080ff',
'fillOpacity': fillOpacity,
'strokeColor': _colorToString(strokeColor) ?? '#000000',
'strokeWidth': strokeWidth,
'strokeOpacity': strokeOpacity,
};
}