Skip to content

Commit

Permalink
feat(fmm): all sorts of small changes (#53)
Browse files Browse the repository at this point in the history
- [x] add badges to readme
- [x] update changelog
- [x] bump version to 0.0.2
- [x] make MarkerLayer rotate in both examples
- [x] add image to readme
  • Loading branch information
josxha authored Nov 5, 2024
1 parent 43b7725 commit 05b59f2
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 9 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions example/lib/flutter_map_maplibre/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class _MapLibreFlutterMapPageState extends State<MapLibreFlutterMapPage> {
],
),
const MarkerLayer(
rotate: true,
markers: [
Marker(
point: LatLng(15, 5),
Expand Down
1 change: 1 addition & 0 deletions example/lib/flutter_map_maplibre/page2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class _FlutterMapMapLibrePageState extends State<FlutterMapMapLibrePage> {
),
const FlutterMapAdapter(
child: fm.MarkerLayer(
rotate: true,
markers: [
fm.Marker(
point: LatLng(15, 5),
Expand Down
5 changes: 5 additions & 0 deletions flutter_map_maplibre/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.0.2

- Enhance documentation and example
- Add package tags

## 0.0.1

- Add `FlutterMapAdapter`
Expand Down
28 changes: 26 additions & 2 deletions flutter_map_maplibre/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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`
Expand All @@ -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) {
Expand Down
25 changes: 19 additions & 6 deletions flutter_map_maplibre/lib/src/maplibre_layer.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -31,19 +33,24 @@ class MapLibreLayer extends StatefulWidget {

class _MapLibreLayerState extends State<MapLibreLayer> {
MapController? _controller;
StreamSubscription<fm.MapEvent>? _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(
Expand All @@ -63,4 +70,10 @@ class _MapLibreLayerState extends State<MapLibreLayer> {
children: widget.children,
);
}

@override
void dispose() {
_streamSub?.cancel();
super.dispose();
}
}
3 changes: 2 additions & 1 deletion flutter_map_maplibre/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 05b59f2

Please sign in to comment.