create static method

Future<Snapshotter> create({
  1. required MapSnapshotOptions options,
  2. OnStyleLoadedListener? onStyleLoadedListener,
  3. OnMapLoadErrorListener? onMapLoadErrorListener,
  4. OnStyleDataLoadedListener? onStyleDataLoadedListener,
  5. OnStyleImageMissingListener? onStyleImageMissingListener,
})

Creates a new Snapshotter instance. The style can be set using style.setStyleURI or style.setStyleJSON.

Implementation

static Future<Snapshotter> create({
  required MapSnapshotOptions options,
  OnStyleLoadedListener? onStyleLoadedListener,
  OnMapLoadErrorListener? onMapLoadErrorListener,
  OnStyleDataLoadedListener? onStyleDataLoadedListener,
  OnStyleImageMissingListener? onStyleImageMissingListener,
}) async {
  final snapshotter = Snapshotter._(
      options: options,
      onStyleLoadedListener: onStyleLoadedListener,
      onMapLoadErrorListener: onMapLoadErrorListener,
      onStyleDataLoadedListener: onStyleDataLoadedListener,
      onStyleImageMissingListener: onStyleImageMissingListener);

  snapshotter._mapEvents._onStyleLoadedListener = onStyleLoadedListener;
  snapshotter._mapEvents._onMapLoadErrorListener = onMapLoadErrorListener;
  snapshotter._mapEvents._onStyleDataLoadedListener =
      onStyleDataLoadedListener;
  snapshotter._mapEvents._onStyleImageMissingListener =
      onStyleImageMissingListener;

  await _snapshotterInstanceManager.setupSnapshotterForSuffix(
      snapshotter._suffix.toString(),
      snapshotter._mapEvents.eventTypes.map((e) => e.index).toList(),
      options);

  Snapshotter._finalizer
      .attach(snapshotter, snapshotter._suffix, detach: snapshotter);
  return snapshotter;
}