How to implement Live Tracking.

554 views
Skip to first unread message

Harsha Vardhan

unread,
Sep 18, 2018, 8:57:28 AM9/18/18
to Flutter Dev
Hello All...

I am using map_view package to show a location for particular user and its working fine but I need a functionality say that if user moves form one place to another place means (around for 5 meters) ill get data through a channel and I want to show that live track thing in my application I want that smoothness say for suppose like Uber tracking like vehicle will be shown moving from one latlong to another latlong.. How is it possible in flutter.

please help me out ..
Thanks in advance.

Belokotov

unread,
Sep 19, 2018, 2:46:31 AM9/19/18
to Flutter Dev
There are two packages in the pub, geolocator and geolocation. Both of them have functionality you are looking for.

Harsha Vardhan

unread,
Sep 24, 2018, 3:57:03 AM9/24/18
to Flutter Dev
Can you please give me an example pleaseee..

Cause I tried so many ways, example

1. Mapview
2. flutter maps
3. location
4. geolocator.

I used all the above package some of them are saying undefined class even though I import package, but where as mapview I got map with marker but I want to update the marker when the data changes.

here is my code :: 

my code

Please help me out, I got stuck from weeks.

Belokotov

unread,
Sep 24, 2018, 4:47:00 AM9/24/18
to Flutter Dev
In example of the geolocator is shown the stream of the location update and listener.you just need to init him in the initstate and listen for the location updates from this stream. Kind of

var locationOptions = LocationOptions(accuracy: LocationAccuracy.best, distanceFilter: 100);
final Stream<Position> positionStream = await Geolocator().getPositionStream(locationOptions);
StreamSubscription<Position> _positionStreamSubscription = positionStream.listen((_position) {
print(_position.longitude.toString());
print(_position.latitude.toString());
});


Harsha Vardhan

unread,
Sep 24, 2018, 5:31:06 AM9/24/18
to Flutter Dev
Yeah but I will enter vehicle long and lat through a websocket value my question is how to implement in a map say for suppose Widget with map and marker which moves based on my lat and long values. I got your answer will give the user who is operating phone location but wat im saying is a user who wants to check his vehicle location which is somewhere else driving by somebody i will get lat and long through a device but how to implement them in a map with moving marker (based on values). U got my question??

Belokotov

unread,
Sep 24, 2018, 5:38:24 AM9/24/18
to Flutter Dev
from example before before listen

double _longitude;
double _latitude;

in the listen instead of print

setState((){
_longitude = _position.longitude;
_latitude = _position.latitude;
})

next

widget build{
return somewidgetmap(
marker: icon.middle_finger,
lng: _longitude,
lat: _latitude
)
Reply all
Reply to author
Forward
0 new messages