livemap 0.5.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

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

Map controller #

Api for the LiveMapController class

Basic map controls #

For basic map controls like center, zoom, add an asset on the map see the Map controller documentation

Livemap 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();
   }

Use the LiveMapSideBar widget or compose your own sidebar:

   /// in a [Stack] widget
   Positioned(
      top: 35.0,
      right: 15.0,
      child: Column(children: <Widget>[
         MapCenterOnLiveMarker(liveMapController: liveMapController),
         MapToggleAutoCenter(liveMapController: liveMapController),
         MapTogglePositionStream(liveMapController: liveMapController),
         MapZoomIn(liveMapController: liveMapController),
         MapZoomOut(liveMapController: liveMapController),
      ])
   )

Tile layers #

Some open tile layers and a tile switcher bar are available:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Stack(
      children: <Widget>[
        LiveMap(
          /// defaults the [tileLayer] property to [TileLayerType.normal]
          controller: liveMapController,
          center: LatLng(51.0, 0.0),
          zoom: 17.0),
        Positioned(
          top: 35.0,
          right: 20.0,
          child: TileLayersBar(controller: liveMapController)),
      ],
    ));
  }

Available layers:

   enum TileLayerType { normal, topography, monochrome, hike }

Custom tile layers bar:

   Positioned(
      top: 35.0,
      right: 15.0,
      child: Column(children: <Widget>[
         // .. other buttons
         MapTileLayerNormal(liveMapController: livemapController),
         MapTileLayerMonochrome(liveMapController: livemapController),
         MapTileLayerTopography(liveMapController: livemapController),
         MapTileLayerHike(liveMapController: livemapController),
      ])
   )

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() () {
       liveMapController = LiveMapController(
         mapController:   MapController(),
         autoCenter: true);
     }

     LiveMapController liveMapController;

     @override
     Widget build(BuildContext context) {
       return Scaffold(
           body: LiveMap(
             controller: liveMapController,
             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']),
           ));
     }

     @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") {
          print("New zoom value: ${change.value}")
        }
      });
   }

   // dispose: _changefeed.cancel();

Changelog #

0.5.0 #

Refactor using the Fluxmap package. Breaking changes in Livemap class intialization:

  • Remove MapOptions parameter
  • Add center parameter
  • Add zoom parameter
  • TileLayer┬áis now optional, defaulting to Open street maps

0.4.0 #

Breaking changes:

  • Fix the tileLayer parameter name
  • Remove the mapController argument for LiveMap

Features:

  • Add a tile layers runtime switching option
  • Composable sidebars

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,
        controller: liveMapController,
        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.5.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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
77
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]
88
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.1+4
  • Flutter: 1.12.13+hotfix.4

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
cupertino_icons ^0.1.2 0.1.3
extra_pedantic ^1.1.1+3 1.1.1+3
flutter 0.0.0
fluttertoast ^3.1.3 3.1.3
fluxmap ^0.1.1 0.1.1
geopoint_location ^0.4.0 0.4.0
map_controller ^0.5.1 0.5.1
pedantic ^1.7.0 1.9.0
Transitive dependencies
ansicolor 1.0.2
async 2.4.0
cached_network_image 1.1.3 2.0.0-rc.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.4
device 0.1.0
df 0.1.0
flutter_cache_manager 1.1.3
flutter_image 2.0.0 3.0.0
flutter_map 0.7.3
geodesy 0.3.2
geodf 0.1.0
geojson 0.7.3
geolocator 5.1.5
geopoint 0.7.0
google_api_availability 2.0.1
http 0.12.0+2
http_parser 3.1.3
injector 1.0.8
intl 0.16.0
iso 0.2.3 0.3.0
jiffy 2.1.2
latlong 0.6.1
location_permissions 2.0.3
logging 0.11.3+2
matcher 0.12.6
meta 1.1.8
ml_linalg 12.7.1
path 1.6.4
path_provider 1.5.1
platform 2.2.1
positioned_tap_detector 1.0.3
provider 3.2.0 4.0.0-dev
quiver 2.1.2+1
rxdart 0.22.6 0.23.1
sky_engine 0.0.99
slugify2 0.2.1
source_span 1.5.5
sqflite 1.1.8 1.2.0-dev.1
stack_trace 1.9.3
string_scanner 1.0.5
synchronized 2.1.1
term_glyph 1.1.0
transparent_image 1.0.0
tuple 1.0.3
typed_data 1.1.6
uuid 2.0.4
validate 1.7.0
vector_math 2.0.8
xrange 0.0.8
Dev dependencies
flutter_test