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

MapView fully loaded callback / MapView Screenshot Functionality #1737

Closed
abinpaul1 opened this issue Sep 5, 2021 · 5 comments
Closed

MapView fully loaded callback / MapView Screenshot Functionality #1737

abinpaul1 opened this issue Sep 5, 2021 · 5 comments

Comments

@abinpaul1
Copy link

Please note: issues related to or caused by osmbonuspack will be closed with a
suggestion to open an issue at https://github.com/MKergall/osmbonuspack

(feel free to delete whatever doesn't apply)

Issue Type

[ ] Question
[ ] Bug
[ X] Improvement
[ ] Build system related
[ ] Performance
[ ] Documentation

Description

Currently there is no option to know when a Mapview is fully loaded with all the tiles. This could be helpful to create a static screenshot of MapView instead of relying on a server-side Static Map API.
A functionality similar to snapshot method in Google's MapView would also be useful.

@monsieurtanuki
Copy link
Collaborator

Hi @abinpaul1!
Actually there's something similar, but maybe not deeply embedded in MapView.
It's called MapSnapshot.
I think you'll find a couple of demos in the sample app: one that creates bitmaps with up-to-date tiles for USA States, and the other that displays on top of the MapView the number of up-to-date and approximated tiles.
Tell me if you do find something close to your needs.

@abinpaul1
Copy link
Author

Yes. That was exactly what was required. Thanks a lot.
I wasnt able to find this functionality easily. I would be happy to add documentation or wiki for this option , if you could point me to where I should.

Just adding the snippet to take snapshot of a Mapview hear incase anyone wants a quick sample

final MapSnapshot mapSnapshot = new MapSnapshot(new MapSnapshot.MapSnapshotable() {
            @Override
            public void callback(final MapSnapshot pMapSnapshot) {
                if (pMapSnapshot.getStatus() != MapSnapshot.Status.CANVAS_OK) {
                    return;
                }
                final Bitmap bitmap = Bitmap.createBitmap(pMapSnapshot.getBitmap());
                // Do something with the bitmap like save to file
            }
        }, MapSnapshot.INCLUDE_FLAG_UPTODATE, pMapView);
new Thread(mapSnapshot).start();

@monsieurtanuki
Copy link
Collaborator

@abinpaul1 Cool! Feel free to create a new page in the wiki.

@abinpaul1
Copy link
Author

@monsieurtanuki
Copy link
Collaborator

@abinpaul1 Well done!

There's another demo that could be interesting for you called "Tile States", based on TileStates. Each time the map is refreshed, the number of up-to-date/expired/scaled/not-found tiles is computed. Less "callback-style" than MapSnapshot, but can be useful too.

Feel free to close this issue.

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

2 participants