parseMarkerToMapbox function

Future<PointAnnotationOptions> parseMarkerToMapbox(
  1. CustomMarker marker
)

Implementation

Future<mapbox.PointAnnotationOptions> parseMarkerToMapbox(
    CustomMarker marker) async {
  final Uint8List markerImage = await marker.getUint8List();

  final Map<Alignment, mapbox.IconAnchor> alignmentToIconAnchor = {
    Alignment.topLeft: mapbox.IconAnchor.TOP_LEFT,
    Alignment.topCenter: mapbox.IconAnchor.TOP,
    Alignment.topRight: mapbox.IconAnchor.TOP_RIGHT,
    Alignment.centerLeft: mapbox.IconAnchor.LEFT,
    Alignment.center: mapbox.IconAnchor.CENTER,
    Alignment.centerRight: mapbox.IconAnchor.RIGHT,
    Alignment.bottomLeft: mapbox.IconAnchor.BOTTOM_LEFT,
    Alignment.bottomCenter: mapbox.IconAnchor.BOTTOM,
    Alignment.bottomRight: mapbox.IconAnchor.BOTTOM_RIGHT,
  };

  return mapbox.PointAnnotationOptions(
    geometry: mapbox.Point(
      coordinates:
          mapbox.Position(marker.position.longitude, marker.position.latitude),
    ),
    image: markerImage,
    iconAnchor: alignmentToIconAnchor[marker.alignment],
    iconRotate: marker.rotation.toDouble(),
  );
}