diff --git a/README.md b/README.md index 2b60a24..7685cf0 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,15 @@ storage backend you would possibly want. A compass for flutter_map that indicates the map rotation. It rotates the map back to north on top when clicked. +### [flutter_map_maplibre](https://pub.dev/packages/flutter_map_maplibre) + +[![Pub Version](https://img.shields.io/pub/v/flutter_map_maplibre)](https://pub.dev/packages/flutter_map_maplibre) +[![likes](https://img.shields.io/pub/likes/flutter_map_maplibre?logo=flutter)](https://pub.dev/packages/flutter_map_maplibre) +[![Pub Popularity](https://img.shields.io/pub/popularity/flutter_map_maplibre)](https://pub.dev/packages/flutter_map_maplibre) + +Performant Mapbox Vector Tiles (MVT) support for flutter_map powered by native +MapLibre SDKs. + ### [flutter_map_mbtiles](https://pub.dev/packages/flutter_map_mbtiles) [![Pub Version](https://img.shields.io/pub/v/flutter_map_mbtiles)](https://pub.dev/packages/flutter_map_mbtiles) diff --git a/example/lib/flutter_map_maplibre/page.dart b/example/lib/flutter_map_maplibre/page.dart index 602250b..e5cce31 100644 --- a/example/lib/flutter_map_maplibre/page.dart +++ b/example/lib/flutter_map_maplibre/page.dart @@ -53,6 +53,7 @@ class _MapLibreFlutterMapPageState extends State { ], ), const MarkerLayer( + rotate: true, markers: [ Marker( point: LatLng(15, 5), diff --git a/example/lib/flutter_map_maplibre/page2.dart b/example/lib/flutter_map_maplibre/page2.dart index a73f3a0..4ad237c 100644 --- a/example/lib/flutter_map_maplibre/page2.dart +++ b/example/lib/flutter_map_maplibre/page2.dart @@ -49,6 +49,7 @@ class _FlutterMapMapLibrePageState extends State { ), const FlutterMapAdapter( child: fm.MarkerLayer( + rotate: true, markers: [ fm.Marker( point: LatLng(15, 5), diff --git a/flutter_map_maplibre/CHANGELOG.md b/flutter_map_maplibre/CHANGELOG.md index 8068a3f..21062d0 100644 --- a/flutter_map_maplibre/CHANGELOG.md +++ b/flutter_map_maplibre/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.0.2 + +- Enhance documentation and example +- Add package tags + ## 0.0.1 - Add `FlutterMapAdapter` diff --git a/flutter_map_maplibre/README.md b/flutter_map_maplibre/README.md index 8e4126e..2c74c57 100644 --- a/flutter_map_maplibre/README.md +++ b/flutter_map_maplibre/README.md @@ -2,11 +2,23 @@ This package offers performant Mapbox Vector Tiles (MVT) support for [flutter_map](https://pub.dev/packages/flutter_map) -powered by native [MapLibre SDKs](https://maplibre.org). +powered by [maplibre](https://pub.dev/packages/maplibre). + +[![Pub Version](https://img.shields.io/pub/v/flutter_map_maplibre)](https://pub.dev/packages/flutter_map_maplibre) +[![likes](https://img.shields.io/pub/likes/flutter_map_maplibre?logo=flutter)](https://pub.dev/packages/flutter_map_maplibre) +[![Pub Points](https://img.shields.io/pub/points/flutter_map_maplibre)](https://pub.dev/packages/flutter_map_maplibre/score) +[![Pub Popularity](https://img.shields.io/pub/popularity/flutter_map_maplibre)](https://pub.dev/packages/flutter_map_maplibre) + +[![GitHub last commit](https://img.shields.io/github/last-commit/josxha/flutter_map_plugins)](https://github.com/josxha/flutter_map_plugins) +[![stars](https://badgen.net/github/stars/josxha/flutter_map_plugins?label=stars&color=green&icon=github)](https://github.com/josxha/flutter_map_plugins/stargazers) +[![GitHub issues](https://img.shields.io/github/issues/josxha/flutter_map_plugins)](https://github.com/josxha/flutter_map_plugins/issues) +[![codecov](https://codecov.io/gh/josxha/flutter_map_plugins/graph/badge.svg?token=5045489G7X)](https://codecov.io/gh/josxha/flutter_map_plugins) + +![Showcase](https://raw.githubusercontent.com/josxha/flutter_map_plugins/1dbc16057899a7aa6ccb57ecc2f9bb1e53c87b0b/showcase.gif) ## Getting started -Add the dependencies to your `pubspec.yaml` file. +1. Add the dependencies to your `pubspec.yaml` file. ```yaml dependencies: @@ -15,6 +27,13 @@ dependencies: maplibre: ^0.1.0 ``` +2. Follow the platform + specific [setup steps](https://flutter-maplibre.pages.dev/docs/category/getting-started) + for the `maplibre` package: + +- [Setup Web](https://flutter-maplibre.pages.dev/docs/getting-started/setup-web) +- [Setup Android](https://flutter-maplibre.pages.dev/docs/getting-started/setup-android) + ## Usage There are two ways how to use bridge the gap between `flutter_map` @@ -31,6 +50,11 @@ the [hosted example app](https://flutter-map-plugins.web.app/). Here we add a `MapLibreMap` as a layer to `FlutterMap` and let flutter_map handle all gesture inputs. +> [!WARNING] +> NOTE: The `MapLibreLayer` has currently a known bug on Android causing it to +> have a high delay and throwing exceptions to the +> console: https://github.com/josxha/flutter_map_plugins/issues/54 + ```dart @override Widget build(BuildContext context) { diff --git a/flutter_map_maplibre/lib/src/maplibre_layer.dart b/flutter_map_maplibre/lib/src/maplibre_layer.dart index 1f38619..5de1c18 100644 --- a/flutter_map_maplibre/lib/src/maplibre_layer.dart +++ b/flutter_map_maplibre/lib/src/maplibre_layer.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/widgets.dart'; import 'package:flutter_map/flutter_map.dart' as fm; import 'package:flutter_map_maplibre/src/extensions.dart'; @@ -31,19 +33,24 @@ class MapLibreLayer extends StatefulWidget { class _MapLibreLayerState extends State { MapController? _controller; + StreamSubscription? _streamSub; @override Widget build(BuildContext context) { final fmCamera = fm.MapCamera.of(context); - // final fmController = fm.MapController.of(context); + final fmController = fm.MapController.of(context); // final fmOptions = fm.MapOptions.of(context); // sync the FlutterMap movement with MapLibreMap - _controller?.moveCamera( - center: fmCamera.center.toPosition(), - zoom: fmCamera.zoom - 1, - bearing: -fmCamera.rotation, - ); + _streamSub ??= fmController.mapEventStream.listen((event) { + if (event case fm.MapEventWithMove()) { + _controller?.moveCamera( + center: event.camera.center.toPosition(), + zoom: event.camera.zoom - 1, + bearing: -event.camera.rotation, + ); + } + }); return MapLibreMap( options: MapOptions( @@ -63,4 +70,10 @@ class _MapLibreLayerState extends State { children: widget.children, ); } + + @override + void dispose() { + _streamSub?.cancel(); + super.dispose(); + } } diff --git a/flutter_map_maplibre/pubspec.yaml b/flutter_map_maplibre/pubspec.yaml index 3ea04ae..af5aba0 100644 --- a/flutter_map_maplibre/pubspec.yaml +++ b/flutter_map_maplibre/pubspec.yaml @@ -1,6 +1,7 @@ name: flutter_map_maplibre description: "Performant Mapbox Vector Tiles (MVT) support for flutter_map powered by native MapLibre SDKs." -version: 0.0.1 +version: 0.0.2 +topics: [ flutter-map, map, vector, maplibre, mvt ] repository: https://github.com/josxha/flutter_map_plugins issue_tracker: https://github.com/josxha/flutter_map_plugins/issues