livemap 0.2.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 69

Livemap #

pub package

A map widget with live position updates. Based on Flutter map and Geolocator. Provides a controller api to handle map state changes.

Screenshot

Controller api #

Api for the LiveMapController class

Map controls #

Zoom #

zoom: get the current zoom value

zoomIn(): increase the zoom level by 1

zoomOut(): decrease the zoom level by 1

Center #

center: get the current center LatLng value

centerOnPosition(Position position ): center the map on a Position

centerOnLiveMarker(): recenter the map on the live position marker

toggleAutoCenter(): toggle the value of autocenter

autoCenter: get the current value of autocenter: used when the position updates are on

Position stream #

togglePositionStreamSubscription(): enable or disable the live position stream

Markers #

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

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

On ready callback #

Execute code right after the map is ready:

   @override
   void initState() {
      liveMapController.onReady.then((_) {
         liveMapController.togglePositionStreamSubscription();
      });
      super.initState();
   }

Example #

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:geolocator/geolocator.dart';
import 'package:livemap/livemap.dart';
import 'package:latlong/latlong.dart';

class LiveMapPage extends StatelessWidget {
  LiveMapPage() () {
    mapController = MapController();
    liveMapController = LiveMapController(mapController: mapController);
  }

  MapController mapController;
  LiveMapController liveMapController;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: LiveMap(
          mapController: mapController,
          liveMapController: liveMapController,
          mapOptions: MapOptions(
            center: LatLng(51.0, 0.0),
            zoom: 13.0,
          ),
          titleLayer: TileLayerOptions(
              urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
              subdomains: ['a', 'b', 'c']),
        ),
        bottomNavigationBar: LiveMapBottomNavigationBar(
          liveMapController: liveMapController,
        ));
  }

  @override
  void dispose() {
    liveMapController.dispose();
    super.dispose();
  }
}

Changefeed #

A changefeed is available: it's a stream with all state changes from the map controller. Ex:

   import 'dart:async';

   StreamSubscription _changefeed;
   int _myzoom;

   liveMapController.onReady.then((_) {
       _myzoom = liveMapController.zoom;
       _changefeed = liveMapController.changeFeed.listen((change) {
        if (change.name == "zoom") {
          setState(() {
              _myzoom = change.value;
          });
        }
      });
   }

   // dispose: _changefeed.cancel();

Changelog #

0.2.0 #

  • Upgrade to Android X
  • Add support for lines
  • Stream state changes from gestures in changefeed
  • Make the marker controller methods async
  • Use more strict linting rules
  • Update dependencies

0.1.0 #

Initial release

example/README.md

Example #

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:livemap/livemap.dart';
import 'package:latlong/latlong.dart';

class SimpleLiveMapPage extends StatefulWidget {
  @override
  _SimpleLiveMapPageState createState() => _SimpleLiveMapPageState();
}

class _SimpleLiveMapPageState extends State<SimpleLiveMapPage> {
  _SimpleLiveMapPageState() {
    mapController = MapController();
    liveMapController = LiveMapController(mapController: mapController);
  }

  MapController mapController;
  LiveMapController liveMapController;

  @override
  void dispose() {
    liveMapController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: LiveMap(
        mapController: mapController,
        liveMapController: liveMapController,
        mapOptions: MapOptions(
          center: LatLng(51.0, 0.0),
          zoom: 17.0,
        ),
        titleLayer: TileLayerOptions(
            urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
            subdomains: ['a', 'b', 'c']),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  livemap: ^0.2.0

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:livemap/livemap.dart';
  
Version Uploaded Documentation Archive
0.2.0 Mar 16, 2019 Go to the documentation of livemap 0.2.0 Download livemap 0.2.0 archive
0.1.0 Mar 1, 2019 Go to the documentation of livemap 0.1.0 Download livemap 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
58
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
50
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

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

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-50 points)

The version constraint in pubspec.yaml does not support the latest published versions for 7 dependencies (3 direct: flutter_map, geopoint, rxdart).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cupertino_icons ^0.1.2 0.1.2
flutter 0.0.0
flutter_map ^0.5.0 0.5.5+2 0.6.1+2
fluttertoast ^3.0.1 3.1.0
geopoint ^0.1.1 0.1.1 0.2.3
rxdart ^0.21.0 0.21.0 0.22.0
slugify2 ^0.2.0 0.2.1
speech_bubble ^0.0.5 0.0.5
Transitive dependencies
ansicolor 1.0.2
async 2.2.0
cached_network_image 0.8.0
charcode 1.1.2
collection 1.14.11
console_log_handler 1.1.6
convert 2.1.1
crypto 2.0.6
flutter_cache_manager 0.3.2
flutter_image 1.0.0 2.0.0-dev.1
geolocator 3.0.1 5.0.1
google_api_availability 2.0.1
http 0.12.0+2
http_parser 3.1.3
intl 0.15.8
latlong 0.6.1
logging 0.11.3+2
matcher 0.12.5
meta 1.1.6 1.1.7
path 1.6.2
path_provider 0.5.0+1 1.1.0
pedantic 1.7.0
permission_handler 3.1.0
positioned_tap_detector 1.0.2
quiver 2.0.3
sky_engine 0.0.99
source_span 1.5.5
sqflite 1.1.5
stack_trace 1.9.3
string_scanner 1.0.4
synchronized 2.1.0+1
term_glyph 1.1.0
transparent_image 1.0.0
tuple 1.0.2
typed_data 1.1.6
uuid 2.0.2
validate 1.7.0
vector_math 2.0.8
Dev dependencies
flutter_test