takeSnapshot method
CancelableOperation<ByteData?>
takeSnapshot({
- Alignment copyrightPosition = sdk.Alignment.bottomRight,
Метод для получения снэпшота карты.
Implementation
CancelableOperation<ByteData?> takeSnapshot({
sdk.Alignment copyrightPosition = sdk.Alignment.bottomRight,
}) {
if (_renderer == null) {
throw NativeException(
'Map must be initialized (getMapAsync completed) before takeSnapshot',
);
}
final completer = Completer<ByteData>();
_renderer!.takeSnapshot(copyrightPosition).value.then(
(imageData) {
final buffer = imageData.data.buffer;
final imageDataList = buffer.asUint8List(
imageData.data.offsetInBytes,
imageData.data.lengthInBytes,
);
final imageWidth = imageData.size.width;
final imageHeight = imageData.size.height;
ui.decodeImageFromPixels(
imageDataList,
imageWidth,
imageHeight,
ui.PixelFormat.rgba8888,
(image) =>
image.toByteData(format: ui.ImageByteFormat.png).then((value) {
final buffer = value?.buffer;
completer.complete(buffer == null ? null : ByteData.view(buffer));
}),
);
},
);
return CancelableOperation.fromFuture(completer.future);
}