-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add compass plugin * add cupertino compass * Update pubspec.yaml * add compass rotation animation * update compass design * update docs and add screenshot * update package description * rename image directory * use hosted image url * fix html tag in md * rename ci job * add tests
- Loading branch information
Showing
19 changed files
with
445 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_map/flutter_map.dart'; | ||
import 'package:flutter_map_compass/flutter_map_compass.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
|
||
class FlutterMapCompassPage extends StatefulWidget { | ||
const FlutterMapCompassPage({super.key}); | ||
|
||
@override | ||
State<FlutterMapCompassPage> createState() => _FlutterMapCompassPageState(); | ||
} | ||
|
||
class _FlutterMapCompassPageState extends State<FlutterMapCompassPage> { | ||
final _mapController = MapController(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
backgroundColor: Colors.white, | ||
title: const Text('flutter_map_compass'), | ||
), | ||
floatingActionButton: Column( | ||
mainAxisAlignment: MainAxisAlignment.end, | ||
children: [ | ||
FloatingActionButton.extended( | ||
heroTag: 'rotateLeft', | ||
label: const Text('Rotate left'), | ||
onPressed: () => rotateMap(-90), | ||
icon: const Icon(Icons.rotate_left), | ||
), | ||
const SizedBox(height: 16), | ||
FloatingActionButton.extended( | ||
heroTag: 'rotateRight', | ||
label: const Text('Rotate right'), | ||
onPressed: () => rotateMap(90), | ||
icon: const Icon(Icons.rotate_right), | ||
), | ||
], | ||
), | ||
body: FlutterMap( | ||
mapController: _mapController, | ||
options: const MapOptions( | ||
initialZoom: 5, | ||
initialCenter: LatLng(48, 9), | ||
maxZoom: 18, | ||
), | ||
children: [ | ||
TileLayer( | ||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', | ||
), | ||
const MapCompass.cupertino(), | ||
], | ||
), | ||
); | ||
} | ||
|
||
void rotateMap(double deltaRotation) { | ||
_mapController.rotate(_mapController.camera.rotation + deltaRotation); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4" | ||
channel: "stable" | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## [1.0.0] yyyy-mm-dd | ||
|
||
- Initial release | ||
- Add `MapCompass` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Joscha Eckert (josxha) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# flutter_map_compass | ||
|
||
A simple compass for flutter_map. It shows the rotation of the map and resets | ||
the rotation back to 0 when tapped. | ||
|
||
[![Pub Version](https://img.shields.io/pub/v/flutter_map_compass)](https://pub.dev/packages/flutter_map_compass) | ||
[![likes](https://img.shields.io/pub/likes/flutter_map_compass?logo=flutter)](https://pub.dev/packages/flutter_map_compass) | ||
[![Pub Points](https://img.shields.io/pub/points/flutter_map_compass)](https://pub.dev/packages/flutter_map_compass/score) | ||
[![Pub Popularity](https://img.shields.io/pub/popularity/flutter_map_compass)](https://pub.dev/packages/flutter_map_compass) | ||
|
||
[![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) | ||
|
||
<img src="https://raw.githubusercontent.com/josxha/flutter_map_plugins/main/flutter_map_compass/images/screenshot.jpg" width="350px" alt="Example screenshot"> | ||
|
||
## Getting started | ||
|
||
Add the following packages to your `pubspec.yaml` file: | ||
|
||
```yaml | ||
dependencies: | ||
flutter_map: ^6.0.0 # in case you don't have it yet | ||
flutter_map_compass: ^1.0.0 # this package | ||
``` | ||
## Usage | ||
```dart | ||
@override | ||
Widget build(BuildContext context) { | ||
return FlutterMap( | ||
options: MapOptions(), | ||
children: [ | ||
TileLayer( | ||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', | ||
), | ||
|
||
// use the default compass that is based on the cupertino compass icon | ||
const MapCompass.cupertino( | ||
hideIfRotatedNorth: true, | ||
), | ||
|
||
// Or use the primary constructor to customize all | ||
const MapCompass( | ||
icon: Icon(Icons.arrow_upward), | ||
hideIfRotatedNorth: true, | ||
), | ||
], | ||
); | ||
} | ||
``` | ||
|
||
## Additional information | ||
|
||
If you need help you | ||
can [open an issue](https://github.com/josxha/flutter_map_plugins/issues/new/choose) | ||
or join | ||
the [`flutter_map` discord server](https://discord.gg/BwpEsjqMAH). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:flutter_lints/flutter.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
### Basic usage | ||
|
||
```dart | ||
@override | ||
Widget build(BuildContext context) { | ||
return FlutterMap( | ||
options: MapOptions(), | ||
children: [ | ||
TileLayer( | ||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', | ||
), | ||
const MapCompass.cupertino(), | ||
], | ||
); | ||
} | ||
``` | ||
|
||
### Need more information? | ||
|
||
- Read | ||
the [README.md](https://github.com/josxha/flutter_map_plugins/blob/main/flutter_map_compass/README.md) | ||
- Check out | ||
the [combined example app](https://github.com/josxha/flutter_map_plugins/tree/main/example) | ||
that showcases this and other flutter_map | ||
packages. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'src/map_compass.dart'; |
Oops, something went wrong.