Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 23 additions & 18 deletions .github/workflows/flutter_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- uses: bluefireteam/melos-action@v3
- name: Lint analysis
Expand All @@ -27,6 +28,7 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- uses: bluefireteam/melos-action@v3
- name: Lint analysis
Expand All @@ -39,6 +41,7 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- uses: bluefireteam/melos-action@v3
- run: melos test:io
Expand All @@ -50,37 +53,48 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- uses: bluefireteam/melos-action@v3
- run: melos test:web

code-gen:
name: "Generate code from templates"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- uses: bluefireteam/melos-action@v3
- run: melos generate
- run: melos format
- name: Check Git changes
uses: multani/git-changes-action@v1

build-android:
name: "Build Android apk"
runs-on: ubuntu-latest
defaults:
run:
working-directory: maplibre_gl_example
strategy:
fail-fast: false
matrix:
sdk: [ '3.22.0', '' ]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.sdk }}
channel: stable
cache: true
- uses: bluefireteam/melos-action@v3
- uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Build example APK
run: flutter build apk
- name: Upload apk as artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.sdk == '' }}
with:
name: maplibre-flutter-demo.apk
path: maplibre_gl_example/build/app/outputs/flutter-apk/app-release.apk
Expand All @@ -91,15 +105,11 @@ jobs:
defaults:
run:
working-directory: maplibre_gl_example
strategy:
fail-fast: false
matrix:
sdk: [ '3.22.0', '' ]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.sdk }}
channel: stable
cache: true
- uses: bluefireteam/melos-action@v3
- uses: maxim-lobanov/setup-cocoapods@v1
Expand All @@ -108,7 +118,6 @@ jobs:
- name: Build iOS package
run: flutter build ios --simulator
- name: Upload Runner.app as artifact
if: ${{ matrix.sdk == '' }}
uses: actions/upload-artifact@v4
with:
name: maplibre-flutter-demo.app
Expand All @@ -120,15 +129,11 @@ jobs:
defaults:
run:
working-directory: maplibre_gl_example
strategy:
fail-fast: false
matrix:
sdk: [ '3.22.0', '' ]
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.sdk }}
channel: stable
cache: true
- uses: bluefireteam/melos-action@v3
- name: Build web
Expand Down
5 changes: 3 additions & 2 deletions maplibre_gl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

### Breaking changes

* Updated maplibre-native for iOS to v6.12.0. This mainly introduces PMTiles support. See the
* Updated maplibre-native for iOS to v6.14.0. This mainly introduces PMTiles support. See the
[maplibre-native changelog](https://github.com/maplibre/maplibre-native/blob/main/platform/ios/CHANGELOG.md#6121)
for more information.
* Updated maplibre-native for Android to v11.8.1. This mainly introduces PMTiles support.
* Updated maplibre-native for Android to v11.9.0. This mainly introduces PMTiles support.
Flutter version packed with OpenGL ES 3.0 build for now, later we could probably switch to Vulkan.
See the [maplibre-native changelog](https://github.com/maplibre/maplibre-native/blob/main/platform/android/CHANGELOG.md#1181)
for more information.
* queryRenderedFeaturesInRect support string feature ids on web (#576).

### Changed

Expand Down
5 changes: 5 additions & 0 deletions maplibre_gl/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<p align="center">
<img src="https://github.com/user-attachments/assets/7ff2cda8-f564-4e70-a971-d34152f969f0#gh-light-mode-only" alt="MapLibre Logo" width="200">
<img src="https://github.com/user-attachments/assets/cee8376b-9812-40ff-91c6-2d53f9581b83#gh-dark-mode-only" alt="MapLibre Logo" width="200">
</p>

# Flutter MapLibre GL

[![Pub Version](https://img.shields.io/pub/v/maplibre_gl)](https://pub.dev/packages/maplibre_gl)
Expand Down
6 changes: 3 additions & 3 deletions maplibre_gl/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
namespace 'org.maplibre.maplibregl'
}

ndkVersion "27.0.12077973"
ndkVersion "28.1.13356709"

defaultConfig {
minSdkVersion 21
Expand All @@ -48,13 +48,13 @@ android {
jvmTarget = JavaVersion.VERSION_1_8
}
dependencies {
implementation 'org.maplibre.gl:android-sdk:11.8.5'
implementation 'org.maplibre.gl:android-sdk:11.9.0'
implementation 'org.maplibre.gl:android-plugin-annotation-v9:3.0.2'
implementation 'org.maplibre.gl:android-plugin-offline-v9:3.0.2'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
}
}

dependencies {
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.core:core-ktx:1.16.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.maplibre.maplibregl

import android.content.Context
import org.maplibre.android.location.LocationComponent
import org.maplibre.android.location.engine.LocationEngine
import org.maplibre.android.location.engine.LocationEngineDefault.getDefaultLocationEngine
import org.maplibre.android.location.engine.LocationEngineProxy
import org.maplibre.android.location.engine.LocationEngineRequest

class LocationEngineFactory {

private var locationEngineRequest: LocationEngineRequest? = null

fun getLocationEngine(context: Context): LocationEngine {
if (locationEngineRequest?.priority == LocationEngineRequest.PRIORITY_HIGH_ACCURACY) {
return LocationEngineProxy(
MapLibreGPSLocationEngine(context)
)
}
return getDefaultLocationEngine(context)
}

fun initLocationComponent(
context: Context,
locationComponent: LocationComponent?,
locationEngineRequest: LocationEngineRequest?
) {
if (locationEngineRequest != null) {
this.locationEngineRequest = locationEngineRequest
}
if (locationComponent != null) {
locationComponent.locationEngine = getLocationEngine(context)
locationEngineRequest?.let { locationEngineRequest ->
locationComponent.locationEngineRequest = locationEngineRequest
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,24 @@
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Pair;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.TextureView;
import android.view.View;
import android.widget.FrameLayout;
import android.util.Pair;

import androidx.annotation.NonNull;
import androidx.lifecycle.DefaultLifecycleObserver;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

import org.maplibre.android.gestures.AndroidGesturesManager;
import org.maplibre.android.gestures.MoveGestureDetector;
import org.maplibre.android.location.engine.LocationEngine;
import org.maplibre.android.location.engine.LocationEngineDefault;
import org.maplibre.android.location.engine.LocationEngineProxy;
import org.maplibre.android.location.engine.LocationEngineRequest;
import org.maplibre.geojson.Feature;
import org.maplibre.geojson.FeatureCollection;
import org.jetbrains.annotations.NotNull;
import org.maplibre.android.camera.CameraPosition;
import org.maplibre.android.camera.CameraUpdate;
import org.maplibre.android.camera.CameraUpdateFactory;
Expand All @@ -49,17 +43,20 @@
import org.maplibre.android.geometry.LatLngBounds;
import org.maplibre.android.geometry.LatLngQuad;
import org.maplibre.android.geometry.VisibleRegion;
import org.maplibre.android.gestures.AndroidGesturesManager;
import org.maplibre.android.gestures.MoveGestureDetector;
import org.maplibre.android.location.LocationComponent;
import org.maplibre.android.location.LocationComponentActivationOptions;
import org.maplibre.android.location.LocationComponentOptions;
import org.maplibre.android.location.OnCameraTrackingChangedListener;
import org.maplibre.android.location.engine.LocationEngineCallback;
import org.maplibre.android.location.engine.LocationEngineRequest;
import org.maplibre.android.location.engine.LocationEngineResult;
import org.maplibre.android.location.modes.CameraMode;
import org.maplibre.android.location.modes.RenderMode;
import org.maplibre.android.maps.MapView;
import org.maplibre.android.maps.MapLibreMap;
import org.maplibre.android.maps.MapLibreMapOptions;
import org.maplibre.android.maps.MapView;
import org.maplibre.android.maps.OnMapReadyCallback;
import org.maplibre.android.maps.Style;
import org.maplibre.android.offline.OfflineManager;
Expand All @@ -72,20 +69,18 @@
import org.maplibre.android.style.layers.Layer;
import org.maplibre.android.style.layers.LineLayer;
import org.maplibre.android.style.layers.Property;
import org.maplibre.android.style.layers.PropertyFactory;
import org.maplibre.android.style.layers.PropertyValue;
import org.maplibre.android.style.layers.RasterLayer;
import org.maplibre.android.style.layers.SymbolLayer;
import org.maplibre.android.style.layers.PropertyFactory;
import org.maplibre.android.style.sources.CustomGeometrySource;
import org.maplibre.android.style.sources.GeoJsonSource;
import org.maplibre.android.style.sources.ImageSource;
import org.maplibre.android.style.sources.Source;
import org.maplibre.android.style.sources.VectorSource;
import org.maplibre.geojson.Feature;
import org.maplibre.geojson.FeatureCollection;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.platform.PlatformView;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
Expand All @@ -98,6 +93,11 @@
import java.util.Map;
import java.util.Set;

import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.platform.PlatformView;


/** Controller of a single MapLibreMaps MapView instance. */
@SuppressLint("MissingPermission")
Expand Down Expand Up @@ -132,6 +132,7 @@ final class MapLibreMapController
private boolean myLocationEnabled = false;
private int myLocationTrackingMode = 0;
private int myLocationRenderMode = 0;
private LocationEngineFactory myLocationEngineFactory = new LocationEngineFactory();
private boolean disposed = false;
private boolean dragEnabled = true;
private MethodChannel.Result mapReadyResult;
Expand Down Expand Up @@ -299,6 +300,7 @@ private void enableLocationComponent(@NonNull Style style) {
LocationComponentActivationOptions
.builder(context, style)
.locationComponentOptions(buildLocationComponentOptions(style))
.locationEngine(myLocationEngineFactory.getLocationEngine(context))
.build();

locationComponent.activateLocationComponent(options);
Expand Down Expand Up @@ -680,7 +682,6 @@ private Pair<Feature, String> firstFeatureOnLayers(RectF in) {

@Override
public void onMethodCall(MethodCall call, MethodChannel.Result result) {

switch (call.method) {
case "map#waitForMap":
if (mapLibreMap != null) {
Expand Down Expand Up @@ -1877,17 +1878,8 @@ public void setCameraTargetBounds(LatLngBounds bounds) {
}

@Override
public void setLocationEngineProperties(LocationEngineRequest locationEngineRequest){
if(locationComponent != null){
if(locationEngineRequest.getPriority() == LocationEngineRequest.PRIORITY_HIGH_ACCURACY){
locationComponent.setLocationEngine(new LocationEngineProxy(
new MapLibreGPSLocationEngine(context)));
} else {
locationComponent.setLocationEngine(
LocationEngineDefault.INSTANCE.getDefaultLocationEngine(context));
}
locationComponent.setLocationEngineRequest(locationEngineRequest);
}
public void setLocationEngineProperties(@NotNull LocationEngineRequest locationEngineRequest) {
myLocationEngineFactory.initLocationComponent(context, locationComponent, locationEngineRequest);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion maplibre_gl/ios/maplibre_gl.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A new Flutter plugin.
s.dependency 'Flutter'
# When updating the dependency version,
# make sure to also update the version in Package.swift.
s.dependency 'MapLibre', '6.12.1'
s.dependency 'MapLibre', '6.14.0'
s.swift_version = '5.0'
s.ios.deployment_target = '12.0'
end
Expand Down
2 changes: 1 addition & 1 deletion maplibre_gl/ios/maplibre_gl/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
dependencies: [
// When updating the dependency version,
// make sure to also update the version in maplibre_gl.podspec.
.package(url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", exact: "6.12.1"),
.package(url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", exact: "6.14.0"),
],
targets: [
.target(
Expand Down
Loading
Loading