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

feat: enhance controller, maplibre-native v11.4.0 #13

Merged
merged 38 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9136f39
add getCamera()
josxha Sep 14, 2024
0685e14
dart format
josxha Sep 14, 2024
0b7bd3e
add tests for flyTo, jumpTo
josxha Sep 14, 2024
e6c27da
Update smoke_test.dart
josxha Sep 14, 2024
dd0549f
use closeTo
josxha Sep 14, 2024
beef120
more tests
josxha Sep 14, 2024
54ca48a
remove usePathUrlStrategy()
josxha Sep 14, 2024
a136965
Create CONTRIBUTING.md
josxha Sep 14, 2024
ea100a4
Create CODE_OF_CONDUCT.md
josxha Sep 14, 2024
ba9df84
Create SECURITY.md
josxha Sep 14, 2024
5e658a8
add funding
josxha Sep 14, 2024
6743a9a
Merge branch 'main' into feat/controller-getCamera
josxha Sep 14, 2024
59f7557
add publish ci
josxha Sep 14, 2024
588c3c8
Update setup-android.md
josxha Sep 14, 2024
0d6671a
add android location permissions
josxha Sep 15, 2024
ca0552e
Update CHANGELOG.md
josxha Sep 15, 2024
a063620
update docs
josxha Sep 15, 2024
ab2d4d3
bump maplibre-native to 11.4.0
josxha Sep 15, 2024
137dee5
Update supported-features.md
josxha Sep 15, 2024
c868f17
add getMetersPerPixelAtLatitude()
josxha Sep 15, 2024
8a3c7d9
fix flyTo cancellation on web
josxha Sep 15, 2024
497f91e
add getVisibleRegion
josxha Sep 15, 2024
a38ef55
fix export
josxha Sep 15, 2024
523432b
fix android package, update changelog
josxha Sep 15, 2024
f2f2201
Update smoke_test.dart
josxha Sep 15, 2024
3476994
disable flyTo cancel test
josxha Sep 15, 2024
cbd689c
Update smoke_test.dart
josxha Sep 15, 2024
837d864
Update smoke_test.dart
josxha Sep 15, 2024
d06d411
Update smoke_test.dart
josxha Sep 15, 2024
99d545f
Update smoke_test.dart
josxha Sep 16, 2024
2947990
disable integration-test-android ci
josxha Sep 16, 2024
503bfac
Update smoke_test.dart
josxha Sep 16, 2024
901f682
add kotlin test file
josxha Sep 16, 2024
d70a2bf
Update smoke_test.dart
josxha Sep 16, 2024
f6e3066
Update smoke_test.dart
josxha Sep 16, 2024
47fa3f1
add code generator script
josxha Sep 16, 2024
89e6ed3
Update CONTRIBUTING.md
josxha Sep 16, 2024
b2d83a6
Update dependabot.yml
josxha Sep 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
version: 2
enable-beta-ecosystems: true
updates:
- package-ecosystem: "pub"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "*"
update-types:
- "version-update:semver-minor"
- "version-update:semver-patch"
- package-ecosystem: "pub"
directory: "/example"
directories:
- "/"
- "/example"
schedule:
interval: "daily"
ignore:
- dependency-name: "*"
update-types:
- "version-update:semver-minor"
- "version-update:semver-patch"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "npm"
directory: "/docs"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
groups:
dependencies:
patterns: [ "*" ]
patterns: [ "*" ]
- package-ecosystem: "gradle"
directories:
- "/android"
- "/example/android"
schedule:
interval: "daily"
62 changes: 31 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,37 @@ jobs:
# cache: true
# - run: flutter pub get
# - run: flutter test integration_test --no-pub -r expanded
integration-test-android:
name: "Integration Tests on Android"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
api-level: [ 23 ] # TODO add 34
timeout-minutes: 30
defaults:
run:
working-directory: example
steps:
- uses: actions/checkout@v4
- name: Setup Flutter SDK
uses: subosito/flutter-action@v2
with:
cache: true
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: "Get Flutter dependencies"
run: flutter pub get
- name: Run integration tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
emulator-boot-timeout: 1800 # 30 minutes
script: cd example && flutter test integration_test -r expanded --timeout=none
# integration-test-android:
# name: "Integration Tests on Android"
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# api-level: [ 23 ] # TODO add 34
# timeout-minutes: 30
# defaults:
# run:
# working-directory: example
# steps:
# - uses: actions/checkout@v4
# - name: Setup Flutter SDK
# uses: subosito/flutter-action@v2
# with:
# cache: true
# - uses: actions/setup-java@v4
# with:
# java-version: '17'
# distribution: 'temurin'
# cache: 'gradle'
# - name: "Get Flutter dependencies"
# run: flutter pub get
# - name: Run integration tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: ${{ matrix.api-level }}
# arch: x86_64
# emulator-boot-timeout: 1800 # 30 minutes
# script: cd example && flutter test integration_test -r expanded --timeout=none
integration-test-web:
name: "Integration Tests on Web"
runs-on: ubuntu-latest
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Publish to pub.dev

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
publish:
permissions:
id-token: write # Required for authentication using OIDC
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
## unreleased

### Features

- add `duration` parameter to `flyTo()`
- `flyTo()` returns after the animation completes or throws an exception if it
has been cancelled

### Bug fixes

- fix `jumpTo()` never returns

## 0.0.1+1

- fix urls to website
- fix urls of screenshots
- fix urls to website and embedded screenshots
- remove unused `plugin_platform_interface` dependency

## 0.0.1
Expand Down
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ you're interested in making contributions:
4. If there are any changes that developers should be aware of, please update
the [CHANGELOG.md](https://github.com/josxha/flutter-maplibre/blob/main/CHANGELOG.md)
file together with your pull request.
5. If you have a pull request that isn't complete yet and want to get
5. If you change the [./pigeons/pigeon.dart](./pigeons/pigeon.dart) file, you'll
have to run the [pigeon](https://pub.dev/packages/pigeon) code generation.
You can use [./pigeons/run_code_gen.sh](./pigeons/run_code_gen.sh)
or [./pigeons/run_code_gen.ps1](./pigeons/run_code_gen.ps1).
6. If you have a pull request that isn't complete yet and want to get
feedback, consider
to [open a draft pull request](https://github.com/josxha/flutter-maplibre/pulls).
This helps others to get
involved into the changes more early and allows to link the pull request to
open issues. Give a quick summary about your changes listing any related
issues that exist. Screenshots and videos are or course welcome, too.
Use a [conventional](https://www.conventionalcommits.org/) title if you like.
6. When your contribution is ready to review, disable the draft state of your
7. When your contribution is ready to review, disable the draft state of your
pull request and update the summary by editing your initial pull request
message. This summary will go into the commit details of the squashed commit.

Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,23 @@ welcome.

#### Run Code Generation

We use code generation from [pigeon](https://pub.dev/packages/pigeon).
If you change the file [pigeons/pigeon.dart](pigeons/pigeon.dart) you'll have
to run the code generator.
Use the generator script (or run the commands yourself) to generate the code.

On unix systems (macos, linux):
```bash
flutter pub global activate pigeon # only once
dart run pigeon --input pigeons/pigeon.dart
cp ios/Classes/Pigeon.g.swift macos/Classes/Pigeon.g.swift
dart format .
./pigeon/run.sh
```

On windows systems:

```powershell
.\pigeon\run.sh
```


#### Test with WebAssembly

This package supports WebAssembly builds! 🥳
Expand Down
3 changes: 2 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ analyzer:
linter:
rules:
lines_longer_than_80_chars: false
flutter_style_todos: false
flutter_style_todos: false
cascade_invocations: false
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ android {
}

dependencies {
implementation 'org.maplibre.gl:android-sdk:11.3.0'
implementation 'org.maplibre.gl:android-sdk:11.4.0'
// implementation 'org.maplibre.gl:android-plugin-annotation-v9:3.0.0'
// implementation 'org.maplibre.gl:android-plugin-offline-v9:3.0.0'
// implementation 'com.squareup.okhttp3:okhttp:4.12.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.josxha.maplibre

import LngLat
import LngLatBounds
import MapCamera
import MapLibreFlutterApi
import MapLibreHostApi
import MapOptions
Expand Down Expand Up @@ -77,8 +79,12 @@ class MapLibreMapController(

override fun onMapReady(mapLibreMap: MapLibreMap) {
this.mapLibreMap = mapLibreMap
this.mapLibreMap.addOnMapClickListener(this)
this.mapLibreMap.addOnMapLongClickListener(this)
if (initialOptions.listensOnClick) {
this.mapLibreMap.addOnMapClickListener(this)
}
if (initialOptions.listensOnLongClick) {
this.mapLibreMap.addOnMapLongClickListener(this)
}
val style = Style.Builder().fromUri(initialOptions.style)
mapLibreMap.setStyle(style) { loadedStyle ->
this.style = loadedStyle
Expand Down Expand Up @@ -146,6 +152,25 @@ class MapLibreMapController(
callback(Result.success(LngLat(latLng.longitude, latLng.latitude)))
}

override fun getCamera(callback: (Result<MapCamera>) -> Unit) {
val position = mapLibreMap.cameraPosition
val target = mapLibreMap.cameraPosition.target!!
val center = LngLat(target.longitude, target.latitude)
val camera = MapCamera(center, position.zoom, position.tilt, position.bearing)
callback(Result.success(camera))
}

override fun getVisibleRegion(callback: (Result<LngLatBounds>) -> Unit) {
val bounds = mapLibreMap.projection.visibleRegion.latLngBounds
val lngLatBounds = LngLatBounds(
bounds.longitudeWest,
bounds.longitudeEast,
bounds.latitudeSouth,
bounds.latitudeNorth
)
callback(Result.success(lngLatBounds))
}

override fun addFillLayer(id: String, sourceId: String, callback: (Result<Unit>) -> Unit) {
mapLibreMap.style?.addLayer(FillLayer(id, sourceId))
callback(Result.success(Unit))
Expand All @@ -169,6 +194,9 @@ class MapLibreMapController(
callback(Result.success(Unit))
}

override fun getMetersPerPixelAtLatitude(latitude: Double): Double =
mapLibreMap.projection.getMetersPerPixelAtLatitude(latitude)

override fun onMapClick(point: LatLng): Boolean {
flutterApi.onClick(LngLat(point.longitude, point.latitude)) { }
return true
Expand Down
Loading