map_controller 0.4.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

Map controller #

pub package

Stateful map controller for Flutter Map. Manage markers, lines and polygons.

Api #

Api for the StatefulMapController class

Map controls #

Zoom #

zoom: get the current zoom value

zoomIn(): increase the zoom level by 1

zoomOut(): decrease the zoom level by 1

zoomTo(Double value): zoom to the provided value

Center #

center: get the current center LatLng value

centerOnPoint(LatLng point): center on the LatLng value

Map assets #

Markers #

addMarker(String name, Marker marker): add a named marker on the map

addMarkers(Map<String, Marker> markers): add several named markers on the map

removeMarker(String name, Marker marker): remove a named marker from the map

removeMarkers(Map<String, Marker> markers): remove several named markers from the map

markers: get the markers that are on the map

namedMarkers: get the markers with their names that are on the map

Lines #

addLine(String name, List<LatLng> points, double width = 1.0, Color color =, bool isDotted = false): add a line on the map

lines: get the lines that are on the map

Polygons #

addPolygon(String name, List<LatLng> points, double width = 1.0, Color color = const Color(0xFF00FF00), double borderWidth = 0.0, Color borderColor = const Color(0xFFFFFF00)): add a polygon on the map

polygons: get the polygons that are on the map

On ready callback #

Execute some code right after the map is ready:

   void initState() {
      statefulMapController.onReady.then((_) {
         setState((_) =>_ready = true);

Changefeed #

A changefeed is available: it's a stream with all state changes from the map controller. Use it to update the map when a change occurs:

   statefulMapController.onReady.then((_) {
       statefulMapController.changeFeed.listen((change) => setState(() {}));

Geojson data #

The map controller can draw on the map from geojson data:

void loadData() async {
  print("Loading geojson data");
  final data = await rootBundle.loadString('assets/airports.geojson');
  await statefulMapController.fromGeoJson(data,
    markerIcon: Icon(Icons.local_airport), verbose: true);

void initState() {
  mapController = MapController();
  statefulMapController = StatefulMapController(mapController: mapController);
  statefulMapController.onReady.then((_) => loadData());
  sub = statefulMapController.changeFeed.listen((change) => setState(() {}));

Changelog #

0.4.1 #

  • Add support for geojson
  • Add the rotate method
  • Update dependencies

0.4.0 #

  • Add map controller change type
  • Add the fromGeoJson method

0.3.0 #

Add methods to add and remove polygons and lines

0.2.0 #

Update dependencies

0.1.0 #

Initial release


example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  map_controller: ^0.4.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:map_controller/map_controller.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
cupertino_icons ^0.1.2 0.1.2
flutter 0.0.0
flutter_map ^0.7.2 0.7.3
geojson ^0.6.0 0.6.0
latlong ^0.6.1 0.6.1
pedantic ^1.6.0 1.8.0+1
rxdart ^0.22.2 0.22.3
Transitive dependencies
ansicolor 1.0.2
async 2.4.0
cached_network_image 1.1.1
charcode 1.1.2
collection 1.14.11 1.14.12
console_log_handler 1.1.6
convert 2.1.1
crypto 2.1.3
flutter_cache_manager 1.1.1
flutter_image 2.0.0
geodesy 0.3.2
geopoint 0.5.0
http 0.12.0+2
http_parser 3.1.3
intl 0.16.0
iso 0.2.3
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
path 1.6.4
path_provider 1.3.0
platform 2.2.1
positioned_tap_detector 1.0.3
quiver 2.0.5
sky_engine 0.0.99
slugify2 0.2.1
source_span 1.5.5
sqflite 1.1.7+1
stack_trace 1.9.3
string_scanner 1.0.5
synchronized 2.1.0+1
term_glyph 1.1.0
transparent_image 1.0.0
tuple 1.0.3
typed_data 1.1.6
uuid 2.0.2
validate 1.7.0
vector_math 2.0.8
Dev dependencies