Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

livemap

a map widget with live position updates. based on flutter map and geolocator. provides a controller api to handle map state changes.

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

live position

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 abuot live position map

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

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.