-
Notifications
You must be signed in to change notification settings - Fork 517
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
Offline region feature #336
Merged
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
307d136
Update MapboxMapBuilder.java
kleeb 6fbde64
Models for offline structure.
jrolinskifdt 423bed2
Extract function for getting mapbox.
jrolinskifdt 3e580b8
Download region
jrolinskifdt c6c6794
Handle downloading region stream.
jrolinskifdt 0fa5cb3
Download regions data.
jrolinskifdt f512e84
Delete region
jrolinskifdt c8e5a54
Fix:
jrolinskifdt 3473e19
WIP example
jrolinskifdt a554cd9
Rename region.
jrolinskifdt 27044f2
WIP
jrolinskifdt 0fb41b2
Show offline map.
jrolinskifdt fcd2923
refactor
jrolinskifdt 206bd4a
Update android dependencies.
jrolinskifdt bccf419
Fixes
jrolinskifdt 9963f57
Working or iOS offline maps implementation
patrykfdt caf2790
Merge branch 'feature/offline' of https://github.com/Asasello225/flut…
patrykfdt 2af6e9d
Finished iOS offline maps implementation
patrykfdt 69f091f
Merge branch 'master' into feature/offline
patrykfdt c5cc0df
test dependencies from git
andrea689 a276ba5
Merge pull request #5 from Asasello225/feature/offline
kleeb 95aa106
add git dependencies
andrea689 71406f6
Merge branch 'master' of https://github.com/tobrun/flutter-mapbox-gl …
4ec5104
Merge branch 'tobrun-master' into feature/offline
0d7d5aa
change git urls to https
andrea689 f14408a
Merge pull request #7 from andrea689/dependencies-from-git
kleeb 16456e7
Merge branch 'master' of https://github.com/tobrun/flutter-mapbox-gl …
7d9d5f2
Update MapboxMapController.java
kleeb 8b2b8a0
Update MapboxMapController.java
kleeb 2a82c18
Delete MapBoxUtils.java
kleeb a796290
Update MapboxMapController.java
kleeb 31e1abb
Update MapboxMapBuilder.java
kleeb 45a9c1c
Delete Flutter.podspec
kleeb 11128ce
Update README.md
kleeb fda5a92
Update README.md
kleeb a90f189
lint fix
1909e6a
added utils
6a1bd26
downgraded gradle plugin
62ca51e
Merge pull request #11 from tobrun/master
kleeb 0197c21
Merge pull request #13 from tobrun/master
kleeb ef34e6e
Allow user to provide accessToken by flutter side.
jrolinskifdt 7c77759
Fix
jrolinskifdt c741f52
Merge branch 'feature/offlinesync' into feature/offline
jrolinskifdt 30c2307
Merge branch 'feature/offline' into accessToken
jrolinskifdt a76e981
Merge pull request #14 from Asasello225/accessToken
kleeb 3424367
Merge branch 'feature/offlinesync' into feature/offline
jrolinskifdt cb8a7fb
rename downloadListOfRegions method
damian-molinski 81be71e
fix json mapping progress
damian-molinski 5ca3cd5
revert method name changes
damian-molinski ba07e85
rename getDownloadListOfRegions to getXYZ
damian-molinski f3b425f
Use default accessToken from main()
damian-molinski acdf387
Merge pull request #15 from Asasello225/hotfix/pr_fixes
3d696a2
Corrections from review and merge to master (0.9.0)
7b61a8a
correcao
7fb27ee
CORRECTION
d69105e
Merge branch 'feature/offlinesync' into master
lfofelipe 4a139ee
Merge pull request #16 from lfofelipe/master
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
android/src/main/java/com/mapbox/mapboxgl/MapBoxUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.mapbox.mapboxgl; | ||
|
||
import android.content.Context; | ||
import android.content.pm.ApplicationInfo; | ||
import android.content.pm.PackageManager; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.mapbox.mapboxsdk.Mapbox; | ||
|
||
abstract class MapBoxUtils { | ||
private static final String TAG = "MapboxMapController"; | ||
|
||
static Mapbox getMapbox(Context context, String accessToken) { | ||
return Mapbox.getInstance(context, accessToken == null ? getAccessToken(context) : accessToken); | ||
} | ||
|
||
private static String getAccessToken(@NonNull Context context) { | ||
try { | ||
ApplicationInfo ai = context.getPackageManager() | ||
.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); | ||
Bundle bundle = ai.metaData; | ||
String token = bundle.getString("com.mapbox.token"); | ||
if (token == null || token.isEmpty()) { | ||
throw new NullPointerException(); | ||
} | ||
return token; | ||
} catch (Exception e) { | ||
Log.e(TAG, "Failed to find an Access Token in the Application meta-data. Maps may not load correctly. " + | ||
"Please refer to the installation guide at https://github.com/tobrun/flutter-mapbox-gl#mapbox-access-token " + | ||
"for troubleshooting advice." + e.getMessage()); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
android/src/main/java/com/mapbox/mapboxgl/OfflineChannelHandlerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.mapbox.mapboxgl; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.google.gson.Gson; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import io.flutter.plugin.common.BinaryMessenger; | ||
import io.flutter.plugin.common.EventChannel; | ||
|
||
public class OfflineChannelHandlerImpl implements EventChannel.StreamHandler { | ||
private EventChannel.EventSink sink; | ||
private Gson gson = new Gson(); | ||
|
||
OfflineChannelHandlerImpl(BinaryMessenger messenger, String channelName) { | ||
EventChannel eventChannel = new EventChannel(messenger, channelName); | ||
eventChannel.setStreamHandler(this); | ||
} | ||
|
||
@Override | ||
public void onListen(Object arguments, EventChannel.EventSink events) { | ||
sink = events; | ||
} | ||
|
||
@Override | ||
public void onCancel(Object arguments) { | ||
sink = null; | ||
} | ||
|
||
void onError(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { | ||
if (sink == null) return; | ||
sink.error(errorCode, errorMessage, errorDetails); | ||
} | ||
|
||
void onSuccess() { | ||
if (sink == null) return; | ||
Map<String, Object> body = new HashMap<>(); | ||
body.put("status", "success"); | ||
sink.success(gson.toJson(body)); | ||
} | ||
|
||
void onStart() { | ||
if (sink == null) return; | ||
Map<String, Object> body = new HashMap<>(); | ||
body.put("status", "start"); | ||
sink.success(gson.toJson(body)); | ||
} | ||
|
||
void onProgress(double progress) { | ||
if (sink == null) return; | ||
Map<String, Object> body = new HashMap<>(); | ||
body.put("status", "progress"); | ||
body.put("progress", progress); | ||
sink.success(gson.toJson(body)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kleeb I'm getting a ClassCastException here every time I try to download an offline region. The reason seems to be that flutter's methods like methodCall.hasArgument() only work if you pass a flutter
Map
orJSONObject
in flutter. Because you pass an already json-encoded String in global.dart:50 this fails. I got it to work by replacing all calls to extractAccessToken() withgson.fromJson(methodCall.arguments.toString(), JsonObject.class).get("accessToken").getAsString()
or
new Gson().fromJson(methodCall.arguments.toString(), JsonObject.class).get("accessToken").getAsString()
After that downloading definitely works. After I delete a region I can still view it offline but I guess that is just because of caching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you look into patching this @kleeb ?