fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.73k stars 860 forks source link

Question - map re-draw completion event. #355

Closed MichalMisiaszek closed 5 years ago

MichalMisiaszek commented 5 years ago

Hi John, Thanks again for great plugin. I have a question. I am calling mapController.fitBounds and then making screenshot of map widget using RepaintBoundary and FocusScope.of(context).requestFocus(FocusNode()); await _capturePng() Unfortunately sometimes map tiles are not refreshed/downloaded or painted before I make screenshot leading to map with grey background. Any idea how I can wait for plugin to complete painting maps ? BTW. Can you have two tile layers (like overlay weather tiles on map) ? Thanks again.

johnpryan commented 5 years ago

You could take a look at the ImageProvider that most TileProvider implementations are using to see if this could be exposed to MapController, but it's not clear to me exactly how that would work

MichalMisiaszek commented 5 years ago

This is an answer to 2nd or 1st question ? :)

johnpryan commented 5 years ago

that was more for the first question, I don't think we have an example of multiple tile layers being used, but it should be possible if the top layer is partially transparent.

MichalMisiaszek commented 5 years ago

Yea, I tried once with layer which suppose to be transparent but it was looking completely opaque, I will try again. For Map drawing, maybe you know better method ? I tried with hidden widgets but it did not work. I basically want to create image file from map with polylines etc ...

johnpryan commented 5 years ago

if you have a small demo it might be easier to debug what's going on, but under the hood we are just using a Stack widget with Positioned widgets. Here's the implementation: https://github.com/johnpryan/flutter_map/blob/master/lib/src/layer/tile_layer.dart#L427

MichalMisiaszek commented 5 years ago

I will create small demo app so we can find solution, thanks !

MichalMisiaszek commented 5 years ago

Hi John, Plugin support multiple TileLayerOptions the trick was to change default background to transparent ! ;) backgroundColor: Colors.transparent It is not super fast but works. I have weather tiles on map tiles and it us usable. Still to solve issue 1.

johnpryan commented 5 years ago

I'm going to close this - please file one issue at a time :)

MichalMisiaszek commented 5 years ago

Ok, I still do not have a solution to map ready event.

johnpryan commented 5 years ago

ok, I've created #377 to track that.