livemap 0.3.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

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

Note: the map controller api has been moved to the map_controller package. The Livemap controller package is now only responsible for the geolocation related controls

Api #

Api for the LiveMapController class

Map controls #

Center #

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

Rotation #

autoRotate: automatically rotate the map from bearing

rotate(double degrees): rotate the map

Position stream #

togglePositionStreamSubscription(): enable or disable the live position stream

On ready callback #

Execute code right after the map is ready:

   @override
   void initState() {
      liveMapController.onLiveMapReady.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,
      autoCenter: true);
  }

  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.3.2 #

  • Update dependencies
  • Add map autorotation from bearing option

0.3.1 #

Update map_controller dependency

0.3.0 #

  • Update dependencies
  • Add support for polygons
  • Move the map controller api to an external package
  • Use pedantic for analysis options

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.3.2

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
71
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on Oct 18, 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

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

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
fluttertoast ^3.1.0 3.1.3
geolocator ^5.1.1+1 5.1.4+1
geopoint ^0.5.0 0.5.0
geopoint_location ^0.3.1 0.3.1
map_controller ^0.4.1 0.4.1
pedantic ^1.6.0 1.8.0+1
rxdart ^0.22.1+1 0.22.4
slugify2 ^0.2.1 0.2.1
speech_bubble ^0.0.5 0.0.6
Transitive dependencies
ansicolor 1.0.2
async 2.4.0
cached_network_image 1.1.2+1 2.0.0-rc
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.3
flutter_image 2.0.1 3.0.0
geodesy 0.3.2
geojson 0.6.0
google_api_availability 2.0.1
http 0.12.0+2
http_parser 3.1.3
intl 0.16.0
iso 0.2.3
latlong 0.6.1
location_permissions 2.0.3
logging 0.11.3+2
matcher 0.12.5
meta 1.1.7
path 1.6.4
path_provider 1.3.1
platform 2.2.1
positioned_tap_detector 1.0.3
quiver 2.0.5
sky_engine 0.0.99
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
flutter_test