A map widget with live position updates for Flutter

Related tags

Map livemap
Overview

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

Example

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

class _LivemapMarkerPageState extends State<LivemapMarkerPage> {
  _LivemapMarkerPageState() {
    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));
  }

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

class LivemapMarkerPage extends StatefulWidget {
  LivemapMarkerPage();

  @override
  _LivemapMarkerPageState createState() => _LivemapMarkerPageState();
}

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

Custom marker

To use a custom live marker:

Marker liveMarkerBuilder(Device device) {
  return Marker(
      point: device.position.point,
      builder: (BuildContext c) => Container(
              child: Icon(
            Icons.location_on,
            size: 45.0,
            color: Colors.orange,
          )));
}

liveMapController = LiveMapController(
   liveMarkerBuilder: liveMarkerBuilder,
   mapController: MapController(),
   autoCenter: true);

On ready callback

Execute code right after the map is ready:

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

Sidebar

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),
   ])
)

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();
You might also like...

A flutter package for select a city from svg map.

A flutter package for select a city from svg map.

City Picker From Map A flutter package for select a city from svg map. Supported countries (+150) are here. Screenshots Getting Started In the pubspec

Nov 17, 2022

Map Picker for Flutter

Map Picker for Flutter

Map Pin Picker A Vendor-free map Library for Easy and Quick Usage. Follow the steps to integrate Google Maps (https://pub.dev/packages/google_maps_flu

Jul 15, 2022

Flutter Google Map Example - Day 41

Flutter Google Map Example - Day 41

Flutter Google Map Example - Day 41 class Afgprogrammer extends Flutter100DaysOfCode { video() { return { "title": "Flutter Google Map Exa

Jan 3, 2023

Flutter plugin to display a simple flat world map with animated points in real time

Flutter plugin to display a simple flat world map with animated points in real time

Flutter Simple Map Flutter plugin to display a simple flat world map with animated points in real time. Can be used as a presentation of online users,

Dec 8, 2022

🌍 Map location picker component for flutter Based on google_maps_flutter

🌍 Map location picker component for flutter Based on google_maps_flutter

google_map_location_picker Location picker using the official google_maps_flutter. I made This plugin because google deprecated Place Picker. Using Pu

Dec 5, 2022

Flutter Google Map Example

Flutter Google Map Example

Flutter Google Map Example A Flutter application demonstrate google map. Preview Listener and Marker Compass MapTypes Plugin google_maps_flutter from

Sep 14, 2021

A Flutter package for place search using MapBox Api and for Static map image

A Flutter package for place search using MapBox Api and for Static map image

About This package provides easy api calls to MapBox Search API. Also, it contains an static map image generator 😆 . Maki Icons can be used now in ma

Dec 2, 2022

How To Integrate Customized Google Map in Flutter

How To Integrate Customized Google Map in Flutter

How To Integrate Customized Google Map in Flutter Let’s develop a customised Google Maps for the best user experience. Visit : https://medium.com/flut

Dec 6, 2022

Flutter Aris Map Application

 Flutter Aris Map Application

Flutter Aris Map Application Version 1️⃣ . 0️⃣ . 0️⃣ ➕ 1️⃣ 4️⃣ Getting Started $ git clone https://github.com/ariscybertech/aris_map.git $ flutter pac

Dec 22, 2022
Comments
  • Rotate icon current location

    Rotate icon current location

    Hello how are you? I wanted to ask another question for you, do you know any plugins or do you have a hint on how I move the user's location icon according to the user's rotation on the mobile? for example, if it turns south the icon will also flip, some way to convert the data from the gyroscope or accelerometer in angle to the icon of the main marker

    opened by aleffabricio 2
  • titleLayer is not defined

    titleLayer is not defined

    Hi,

    I'm using flutter 1.12 stable and using Livemap (using master code to resolve dependencies)

    Pubspec.yml

    livemap: git: url: [email protected]:synw/livemap.git ref: master

    titleLayer: TileLayerOptions( urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", subdomains: ['a', 'b', 'c']), ),

    Error: titleLayer is not defined. Any thoughts?

    api change 
    opened by AteqEjaz 2
Releases(0.6.0)
Owner
"All that is gold does not glitter, not all those who wander are lost". Tolkien
null
Stateful map controller for Flutter Map

Map controller Stateful map controller for Flutter Map. Manage markers, lines and polygons. View the web demo Usage import 'dart:async'; import 'packa

null 55 Sep 15, 2022
A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC.

A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC. Through the combination of 5g + AI, colle

null 24 Jan 14, 2022
Custom map markers - Custom Map Markers Using Flutter

Custom Map Markers Not only "Everything is a widget" also "Everywhere is a widge

null 8 Oct 19, 2022
Customized google map with widget markers. Enables to show markers with widget code.

widget_marker_google_map Google map with widget markers. Set up Follow the steps on google_maps_flutter document. Usage Same as google_maps_flutter ex

Santa Takahashi 8 Dec 4, 2022
Localizator is a flutter application that provides your current/given position,and gives you weather Forecasts

Locativity Locativity is a flutter application implements flutter_map and Geolocator plugins to provide your current/given position then render it on

Houssemeddine Souissi 48 Nov 6, 2022
Localizator is a flutter application that provides your current/given position,and gives you weather Forecasts

Locativity Locativity is a flutter application implements flutter_map and Geolocator plugins to provide your current/given position then render it on

Houssemeddine Souissi 48 Nov 6, 2022
A Flutter map widget inspired by Leaflet

flutter_map A Dart implementation of Leaflet for Flutter apps. Installation Add flutter_map to your pubspec: dependencies: flutter_map: any # or the

null 2.2k Dec 28, 2022
A Flutter map widget inspired by Leaflet

flutter_map A Dart implementation of Leaflet for Flutter apps. Usage Add flutter_map to your pubspec: dependencies: flutter_map: any # or the latest

AppTree Software, Inc 114 Dec 13, 2022
A Flutter map widget inspired by Leaflet

flutter_map A Dart implementation of Leaflet for Flutter apps. Installation Add flutter_map to your pubspec: dependencies: flutter_map: any # or the

null 2.2k Jan 3, 2023
A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

A new flutter plugin for mapbox. You can use it for your map backgrounds inside flutter applications

Boris Gautier 5 Sep 14, 2022