toJson method

Map<String, dynamic> toJson()

Converts this polyline to a JSON object for serialization.

This is used to pass polyline data to the HTML map view.

Implementation

Map<String, dynamic> toJson() {
  return {
    'id': id,
    'coordinates': coordinates
        .map((coord) => {'lat': coord.latitude, 'lng': coord.longitude})
        .toList(),
    'color': _colorToString(color) ?? '#0080ff',
    'width': width,
    'opacity': opacity,
    'isDashed': isDashed,
  };
}