Skip to content

Commit

Permalink
Merge branch 'master' into av-web
Browse files Browse the repository at this point in the history
* master:
  [flutter] release v0.6.0
  Change gradle version to 3.5.0 instead of 3.6.1
  Update Mapbox plugins and gradle
  iOS: add long press handler (#268)
  [android] Implemented long click for Android (#198)
  [fix] Change default MyLocationTrackingMode to None (#285)
  Add First-Class Support For Listening to `onCameraIdle` events (#280)
  CI: use stable flutter channel also on iOS (#270)
  Implement addImage() to style (#269)
  Add animation duration for animateCamera (#259)
  Document onStyleLoadedCallback (#257)
  example: rename Page to ExamplePage (#258)
  • Loading branch information
andrea689 committed Jun 3, 2020
2 parents c7e364e + aa28848 commit 1bc72b8
Show file tree
Hide file tree
Showing 33 changed files with 299 additions and 70 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/flutter_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs:
name: "Static code analysis"
runs-on: ubuntu-latest


steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
Expand All @@ -29,24 +28,21 @@ jobs:
java-version: '12.x'
- uses: subosito/flutter-action@v1
- run: flutter pub get

- name: Build example APK
run: cd example && flutter build apk
# We might want to add a flutter test step in the future, when there actually are tests for this plugin

build-iOS:
name: Build iOS package
runs-on: macos-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
- name: Upgrade flutter
run: |
flutter channel master
flutter upgrade
- run: flutter pub get
- name: build iOS package
run: |
cd ./example
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 0.0.6, May 31, 2019
* Update mapbox depdendency to 9.2.0 (android) and 5.6.0 (iOS)
* Long press handlers for both iOS as Android
* Change default location tracking to none
* OnCameraIdle listener support
* Add image to style
* Add animation duration to animateCamera
* Content insets
* Visible region support on iOS
* Numerous bug fixes

## 0.0.5, December 21, 2019
* iOS support for annotation extensions (circle, symbol, line)
* Update SDK to 8.5.0 (Android) and 5.5.0 (iOS)
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ embedded interactive and customizable vector maps inside a Flutter widget by emb
![screenshot.png](screenshot.png)

## Install

This project is available on [pub.dev](https://pub.dev/packages/mapbox_gl), follow the [instructions](https://flutter.dev/docs/development/packages-and-plugins/using-packages#adding-a-package-dependency-to-an-app) to integrate a package into your flutter application.

## :new: :new: Who's using this SDK :new: :new:
Expand Down Expand Up @@ -48,6 +49,13 @@ Add these lines to your Info.plist
<string>YOUR_TOKEN_HERE</string>
```

If you access your users' location, you should also add the following key to your Info.plist to explain why you need access to their location data:

```xml
<key>NSLocationWhenInUseUsageDescription</key>
<string>[Your explanation here]</string>
```

##### Web

Add mapbox-gl.js library in the `<head>` of your html page:
Expand All @@ -70,6 +78,8 @@ Add your `accessToken` in a script tag at the end of your body:
</body>
```

Mapbox [recommends](https://docs.mapbox.com/help/tutorials/first-steps-ios-sdk/#display-the-users-location) the explanation "Shows your location on the map and helps improve the map".

## Supported API

| Feature | Android | iOS | Web |
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:8.5.0"
implementation "com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v8:0.7.0"
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v8:0.11.0'
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.0"
implementation "com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0"
implementation "com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0"
}
compileOptions {
sourceCompatibility 1.8
Expand Down
60 changes: 44 additions & 16 deletions android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ final class MapboxMapController
MapboxMap.OnCameraMoveStartedListener,
OnAnnotationClickListener,
MapboxMap.OnMapClickListener,
MapboxMap.OnMapLongClickListener,
MapboxMapOptionsSink,
MethodChannel.MethodCallHandler,
com.mapbox.mapboxsdk.maps.OnMapReadyCallback,
Expand Down Expand Up @@ -124,6 +125,7 @@ final class MapboxMapController
private LocationComponent locationComponent = null;
private LocationEngine locationEngine = null;
private LocalizationPlugin localizationPlugin;
private Style style;

MapboxMapController(
int id,
Expand Down Expand Up @@ -319,6 +321,7 @@ public void setStyleString(String styleString) {
Style.OnStyleLoaded onStyleLoadedCallback = new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
MapboxMapController.this.style = style;
enableLineManager(style);
enableSymbolManager(style);
enableCircleManager(style);
Expand All @@ -328,6 +331,7 @@ public void onStyleLoaded(@NonNull Style style) {
// needs to be placed after SymbolManager#addClickListener,
// is fixed with 0.6.0 of annotations plugin
mapboxMap.addOnMapClickListener(MapboxMapController.this);
mapboxMap.addOnMapLongClickListener(MapboxMapController.this);

localizationPlugin = new LocalizationPlugin(mapView, mapboxMap, style);

Expand Down Expand Up @@ -459,24 +463,28 @@ public void onCancel() {
}
case "camera#animate": {
final CameraUpdate cameraUpdate = Convert.toCameraUpdate(call.argument("cameraUpdate"), mapboxMap, density);
if (cameraUpdate != null) {
// camera transformation not handled yet
mapboxMap.animateCamera(cameraUpdate, new OnCameraMoveFinishedListener(){
@Override
public void onFinish() {
super.onFinish();
result.success(true);
}
final Integer duration = call.argument("duration");

@Override
public void onCancel() {
super.onCancel();
result.success(false);
}
});
final OnCameraMoveFinishedListener onCameraMoveFinishedListener = new OnCameraMoveFinishedListener(){
@Override
public void onFinish() {
super.onFinish();
result.success(true);
}

// animateCamera(cameraUpdate);
}else {
@Override
public void onCancel() {
super.onCancel();
result.success(false);
}
};
if (cameraUpdate != null && duration != null) {
// camera transformation not handled yet
mapboxMap.animateCamera(cameraUpdate, duration, onCameraMoveFinishedListener);
} else if (cameraUpdate != null) {
// camera transformation not handled yet
mapboxMap.animateCamera(cameraUpdate, onCameraMoveFinishedListener);
} else {
result.success(false);
}
break;
Expand Down Expand Up @@ -644,6 +652,14 @@ public void onFailure(@NonNull Exception exception) {
}
break;
}
case "style#addImage":{
if(style==null){
result.error("STYLE IS NULL", "The style is null. Has onStyleLoaded() already been invoked?", null);
}
style.addImage(call.argument("name"), BitmapFactory.decodeByteArray(call.argument("bytes"),0,call.argument("length")), call.argument("sdf"));
result.success(null);
break;
}
default:
result.notImplemented();
}
Expand Down Expand Up @@ -742,6 +758,18 @@ public boolean onMapClick(@NonNull LatLng point) {
return true;
}

@Override
public boolean onMapLongClick(@NonNull LatLng point) {
PointF pointf = mapboxMap.getProjection().toScreenLocation(point);
final Map<String, Object> arguments = new HashMap<>(5);
arguments.put("x", pointf.x);
arguments.put("y", pointf.y);
arguments.put("lng", point.getLongitude());
arguments.put("lat", point.getLatitude());
methodChannel.invokeMethod("map#onMapLongClick", arguments);
return true;
}

@Override
public void dispose() {
if (disposed) {
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.5.0'
}
}

Expand Down
4 changes: 2 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Mon May 25 15:33:34 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
1 change: 1 addition & 0 deletions example/android/settings_aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'
14 changes: 1 addition & 13 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1C318FD9FE81A3CF826CB6E0 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9C618A260D4CE68F2F89632 /* Pods_Runner.framework */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
Expand All @@ -28,8 +24,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -41,15 +35,13 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
33EB4B753D90FC406A268B9A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
647A9CC8EAD456F68D57F590 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
77F62DAA39FA47F19A7FF5D8 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
Expand All @@ -64,8 +56,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
1C318FD9FE81A3CF826CB6E0 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -84,9 +74,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
Expand Down Expand Up @@ -232,7 +220,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
61A6A5795B0A22D55417D672 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion example/lib/animate_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:mapbox_gl/mapbox_gl.dart';

import 'page.dart';

class AnimateCameraPage extends Page {
class AnimateCameraPage extends ExamplePage {
AnimateCameraPage()
: super(const Icon(Icons.map), 'Camera control, animated');

Expand Down
2 changes: 1 addition & 1 deletion example/lib/full_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:mapbox_gl/mapbox_gl.dart';

import 'page.dart';

class FullMapPage extends Page {
class FullMapPage extends ExamplePage {
FullMapPage()
: super(const Icon(Icons.map), 'Full screen map');

Expand Down
1 change: 1 addition & 0 deletions example/lib/generated_plugin_registrant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:mapbox_gl_web/mapbox_gl_web.dart';

import 'package:flutter_web_plugins/flutter_web_plugins.dart';

// ignore: public_member_api_docs
void registerPlugins(PluginRegistry registry) {
MapboxMapPlugin.registerWith(registry.registrarFor(MapboxMapPlugin));
registry.registerMessageHandler();
Expand Down
2 changes: 1 addition & 1 deletion example/lib/line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:mapbox_gl/mapbox_gl.dart';

import 'page.dart';

class LinePage extends Page {
class LinePage extends ExamplePage {
LinePage() : super(const Icon(Icons.share), 'Line');

@override
Expand Down
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'place_circle.dart';
import 'place_symbol.dart';
import 'scrolling_map.dart';

final List<Page> _allPages = <Page>[
final List<ExamplePage> _allPages = <ExamplePage>[
MapUiPage(),
FullMapPage(),
AnimateCameraPage(),
Expand All @@ -29,7 +29,7 @@ final List<Page> _allPages = <Page>[
];

class MapsDemo extends StatelessWidget {
void _pushPage(BuildContext context, Page page) async {
void _pushPage(BuildContext context, ExamplePage page) async {
if (!kIsWeb) {
final location = Location();
final hasPermissions = await location.hasPermission();
Expand Down
11 changes: 9 additions & 2 deletions example/lib/map_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final LatLngBounds sydneyBounds = LatLngBounds(
northeast: const LatLng(-33.571835, 151.325952),
);

class MapUiPage extends Page {
class MapUiPage extends ExamplePage {
MapUiPage() : super(const Icon(Icons.map), 'User interface');

@override
Expand Down Expand Up @@ -235,7 +235,14 @@ class MapUiBodyState extends State<MapUiBody> {
myLocationTrackingMode: _myLocationTrackingMode,
myLocationRenderMode: MyLocationRenderMode.GPS,
onMapClick: (point, latLng) async {
print("${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}");
print("Map click: ${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}");
List features = await mapController.queryRenderedFeatures(point, [],null);
if (features.length>0) {
print(features[0]);
}
},
onMapLongClick: (point, latLng) async {
print("Map long press: ${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}");
List features = await mapController.queryRenderedFeatures(point, [],null);
if (features.length>0) {
print(features[0]);
Expand Down
3 changes: 2 additions & 1 deletion example/lib/move_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:mapbox_gl/mapbox_gl.dart';

import 'page.dart';

class MoveCameraPage extends Page {
class MoveCameraPage extends ExamplePage {
MoveCameraPage() : super(const Icon(Icons.map), 'Camera control');

@override
Expand Down Expand Up @@ -41,6 +41,7 @@ class MoveCameraState extends State<MoveCamera> {
height: 200.0,
child: MapboxMap(
onMapCreated: _onMapCreated,
onCameraIdle: ()=>print("onCameraIdle"),
initialCameraPosition:
const CameraPosition(target: LatLng(0.0, 0.0)),
),
Expand Down
Loading

0 comments on commit 1bc72b8

Please sign in to comment.