Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing documentation for MapSnapshotter and MapSnapshot #279

Open
lemonderon opened this issue Oct 19, 2023 · 3 comments
Open

Missing documentation for MapSnapshotter and MapSnapshot #279

lemonderon opened this issue Oct 19, 2023 · 3 comments

Comments

@lemonderon
Copy link

I am currently trying to make a screenshot of my MapWidget.

I've used https://pub.dev/packages/screenshot package which can only take a snapshot of native AndroidView and not the UIKitView (iOS). There is an ongoing issue with the screen capture which uses RenderRepaintBoundary. The last trace of it is here: flutter/flutter#97853.

I really need to make a screenshot of the map on iOS platform.


Classes generated by pigeon inside map_interfaces.dart contain:
MapSnapshot - /// An image snapshot of a map rendered by `map snapshotter`.
MapSnapshotter -/// MapSnapshotter exposes functionality to capture static map images.
and that basically all the information I've found about them. Whenever I try to instantiate them, I am getting PlatformException(channel-error, Unable to establish connection on channel., null, null)


I've also looked up into official documentation for Android and iOS and have found some implementation in kotlin and swift. For iOS the latest mention in official documentation is for MapBox SDK v9.

Swift code for the problem I'm trying to solve:

MapSnapshotter.Options snapShotOptions = new MapSnapshotter.Options(500, 500);
snapShotOptions.withRegion(mapboxMap.getProjection().getVisibleRegion().latLngBounds);
snapShotOptions.withStyle(mapboxMap.getStyle().getUrl());
MapSnapshotter mapSnapshotter = new MapSnapshotter(this, snapShotOptions);
mapSnapshotter.start(new MapSnapshotter.SnapshotReadyCallback() {
	@Override
	public void onSnapshotReady(MapSnapshot snapshot) {
 
	// Display, share, or use bitmap image how you'd like
 
	Bitmap bitmapImage = snapshot.getBitmap();
	}
});

I've tried to reproduce this Swift code in flutter, but the package seems to missing the required APIs.

@gangoappdev
Copy link

Facing the same problem, any workaround @lemonderon ?

@lemonderon
Copy link
Author

@gangoappdev try using Static Images API from Mapbox (https://docs.mapbox.com/api/maps/static-images/). It worked well for me. You can exactly match the viewport of what the user sees in the app. Also, the API allows drawing vectors on the map and putting images (deployed on CDN).

@evil159
Copy link
Contributor

evil159 commented Apr 30, 2024

Hi all, thank you for your interest in snapshotter, we've implemented snapshotting capabilities in #512 and #513 which should be a part of the next beta release.

@evil159 evil159 mentioned this issue Apr 30, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants