Polaris Map Editor
PolarisMapEditor is a Flutter library for creating map editors with a celestial touch, allowing users to interactively draw areas on the map. The library is inspired by the concept of Polaris, the North Star, providing a reliable point of reference.
Getting started
Import the library into your Dart code:
import 'package:polaris_map_editor/polaris_map_editor.dart';
How to Use
PolarisMapEditor Widget
import 'package:polaris_map_editor/polaris_map_editor.dart';
PolarisMapEditor(
mapController: mapController,
options: PolarisOptions.defaultOptions(
color: Colors.deepPurple,
// optional: enable search places
googlePlaceApiKey: Platform.isMacOS || Platform.isIOS
? Config.googlePlaceIosKey
: Config.googlePlaceAndroidKey,
),
onAreaChanged: print,
child: FlutterMap(
mapController: mapController,
options: MapOptions(
interactionOptions: InteractionOptions(
cursorKeyboardRotationOptions:
CursorKeyboardRotationOptions.disabled(), // prevent shortcuts
),
),
children: const [
OpenStreeTileLayer(), // replace with your tile layer
PolarisLayer(), // <===== Polaris widget, includes AreaLayer, LinesLayer and PointsLayer
],
),
)
PolarisOptions
The core widget responsible for customizing the Polaris map editor. Integrates seamlessly with Flutter Map and provides customization options.
factory PolarisOptions.defaultOptions({
Color color = Colors.blue,
String? googlePlaceApiKey,
}) {
return PolarisOptions(
menu: const MenuOptions(
enabled: true,
),
area: AreaOptions(
color: color.withOpacity(0.3),
isFilled: true,
),
line: LineOptions(
color: color,
strokeWidth: 3,
),
draggedLine: LineOptions(
color: color,
strokeWidth: 3,
isDotted: true,
),
point: PointOptions(
icon: Icon(
Icons.circle,
color: color,
size: 14,
),
lastPointIcon: Stack(
fit: StackFit.expand,
children: [
Icon(
Icons.circle,
color: color,
size: 10,
),
Icon(
Icons.circle_outlined,
color: color,
size: 19,
),
],
),
),
place: googlePlaceApiKey != null
? PlaceOptions.googleMapService(apiKey: googlePlaceApiKey)
: null,
mouse: const MouseOptions(),
shortcut: const ShortcutOptions(
undo: [
[LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyZ],
[LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.keyZ],
],
redo: [
[LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyY],
[LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.keyY],
[
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.shiftLeft,
LogicalKeyboardKey.keyZ
],
[
LogicalKeyboardKey.metaLeft,
LogicalKeyboardKey.shiftLeft,
LogicalKeyboardKey.keyZ
],
],
search: [
[LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyF],
[LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.keyF],
],
zoomIn: [
[LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.add],
[LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.equal],
[LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.add],
[LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.equal],
[
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.shiftLeft,
LogicalKeyboardKey.add
],
[
LogicalKeyboardKey.metaLeft,
LogicalKeyboardKey.shiftLeft,
LogicalKeyboardKey.add
],
],
zoomOut: [
[LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.minus],
[LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.minus],
],
fitCameraToArea: [
[LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyH],
[LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.keyH],
],
deletePoint: [
[LogicalKeyboardKey.controlLeft],
],
),
);
}
Contributing
Contributions are welcome! If you encounter any issues or have suggestions, feel free to open an issue or submit a pull request.
License
This project is licensed under the BSD 3-Clause License.
Libraries
- bloc/editor/editor_bloc
- bloc/map/map_bloc
- bloc/place/place_bloc
- contracts/place_repository
- enums/drag_type
- enums/shortcut
- enums/status_fetch_data
- models/drag
- models/editor
- models/place
- options/area_options
- options/line_options
- options/mouse_options
- options/place_options
- options/point_options
- options/polaris_options
- options/shortcut_options
- polaris_map_editor
- polaris_map_editor_dependencies
- services/google_maps_place_service
- support/helpers
- widgets/layers/area_layer
- widgets/layers/lines_layer
- widgets/layers/points_layer
- widgets/menu/divider_vertical
- widgets/polaris_keyboard_listener
- widgets/polaris_layer
- widgets/polaris_map_editor
- widgets/polaris_search_places_automplete