Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

hafiz703
Copy link

@hafiz703 hafiz703 commented May 28, 2020

With reference to #88 , I have implemented the following,

  • Offline Tile Downloader (offline#downloadOnClick)
  • Offline Tiles List (offline#getDownloadedTiles)
  • Delete Offline Tiles (offline#deleteDownloadedTiles)
  • Navigate to Offline Tile (offline#navigateToRegion)

The implementations are localised in MapboxOfflineManager.java and OfflineManager.swift respectively.

image

Areas to improve:

  • Download progress bar currently done natively (UIProgressView in ios and Notification Progress in android) can be implemented in flutter

  • Once download has started, another concurrent download should be prevented,

@tonnyavery
Copy link
Contributor

At the moment I am using flutter_downloader to have background download notifications on both iOS and Android. Does this PR also add this functionality? Are maps downloadable in the background?

private void launchDownload(String regName) {
// Set up an observer to handle download progress and
// notify the user when the region is finished downloading
final NotificationCompat.Builder downloadNotification = new NotificationCompat.Builder(context, CHANNEL_1_ID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be best to expose at least notification title into Flutter, so that users of the library have control over that. Example usage would be to have localized titles, for example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, users of the library would probably want to have their own icon on the download notification

@tonnyavery
Copy link
Contributor

https://docs.mapbox.com/accounts/overview/pricing/#adjust-the-tile-limit-per-user
There is a way to adjust tiles limit per user for offline maps. This functionality should probably be also exposed for offline manager

});

setStyleString(styleStringInitial);
mapboxOfflineManager = new MapboxOfflineManager(context,this.mapboxMap,registrar);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know exactly the details, but is this map controller destroyed on rotation?
Would this mean that MapboxOfflineManager will also be destroyed with all it's callbacks inside loosing the download state?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not destroyed, but it would be preferable to be able to download regions independent from any maps. For example, a dev might want to always download a certain city the first time a "local guide" app is launched.


@Override
public void onError(OfflineRegionError error) {
Log.d(TAG,"error: "+error.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a way to listen on download state from the flutter side?

if let channel = channel {
channel.invokeMethod("map#onStyleLoaded", arguments: nil)
}
_ = OfflineManager(mapview:mapView,registrar: registrar)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as on Android. What would happen with OfflineManager instance on rotation and calls?

func deleteRegion(index:Int){
var result :[AnyObject] = []
if let offlinePacks = MGLOfflineStorage.shared.packs {
// let allPacks = offlinePacks[index]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably can be removed

@m0nac0
Copy link
Collaborator

m0nac0 commented May 29, 2020

@hafiz703 Thank you a lot for contributing this important feature!
I'll try to take a closer look soon, but some general comments:

  • Looks like there's a number of files in the PR that shouldn't be commited to source control, could you please remove those?
  • Edit: I really don't mean to be rude here, but I think I honestly prefer @maximumbuster 's approach of handling the downloading in GlobalMethodHandler independent of any map instance, as well as allowing users to specify any area to download. Maybe you can take a look at his code samples and kind of "merge" your approaches? That'd be 🔥
  • Regarding the notifications: It'd be great if we could provide a callback to flutter and let users handle displaying the progress notification (Some might want to display a progress bar, others a notification etc.)

Also feel free to let me know if you'd like me to help out with this, as it's not an easy feature!

@hafiz703
Copy link
Author

Thanks for the review @m0nac0 @AAverin. I will work on providing the callback to flutter, removing unnecessary file commits and also expose the method for tile limits. As for handling the downloading in GlobalMethodHandler, would it be possible for @maximumbuster to merge this later on?

@jk-hub
Copy link

jk-hub commented Jun 11, 2020

With reference to #88 , I have implemented the following,

  • Offline Tile Downloader (offline#downloadOnClick)
  • Offline Tiles List (offline#getDownloadedTiles)
  • Delete Offline Tiles (offline#deleteDownloadedTiles)
  • Navigate to Offline Tile (offline#navigateToRegion)

The implementations are localised in MapboxOfflineManager.java and OfflineManager.swift respectively.

image

Areas to improve:

  • Download progress bar currently done natively (UIProgressView in ios and Notification Progress in android) can be implemented in flutter
  • Once download has started, another concurrent download should be prevented,

when will this feature get live into master we required it for our app please merge this commit as soon as possible

@hafiz703 hafiz703 marked this pull request as draft June 16, 2020 17:45
@hafiz703 hafiz703 marked this pull request as ready for review June 18, 2020 17:02
@hafiz703
Copy link
Author

Hi, I have refactored the codes for the offlineManager into MapboxController, exposed download progress and setting of tile limits in dart/flutter.

As for the download of offline tiles independent of maps, it probably could be a future PR but I think this is a good starting point.

@m0nac0
Copy link
Collaborator

m0nac0 commented Jul 17, 2020

@hafiz703 I'm really sorry about this, but I wanted to give a heads up that @kleeb and you seem to have worked on this feature in parallel, unfortunately. After taking a closer look at both, at this time #336 is closer to being merged IMHO. (I don't want to anticipate the review or anyone else's opinion, just letting you know so you can evaluate if you want to put more effort into this.)
I really hope this doesn't discourage you from contributing in the future and please feel free to reach out if you'd like to tackle one of our other open issues or contribute a different feature and have any questions.

@Djcharles26
Copy link

Please approve this, :(, its really necessary

@tobrun
Copy link
Collaborator

tobrun commented Dec 19, 2020

@hafiz703 I'm really sorry about this, but I wanted to give a heads up that @kleeb and you seem to have worked on this feature in parallel, unfortunately. After taking a closer look at both, at this time #336 is closer to being merged IMHO. (I don't want to anticipate the review or anyone else's opinion, just letting you know so you can evaluate if you want to put more effort into this.)
I really hope this doesn't discourage you from contributing in the future and please feel free to reach out if you'd like to tackle one of our other open issues or contribute a different feature and have any questions.

Apologies for the duplicated work but we are moving forward with #366. I do really appreciate the time and effort put into moving this project further!

@tobrun tobrun closed this Dec 19, 2020
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

Successfully merging this pull request may close these issues.

6 participants