listenLocation method
Returns a bool
Implementation
Future<bool> listenLocation(dynamic data) {
_timer = Timer.periodic(Duration(milliseconds: data['time']), (Timer time) {
MapOptions _mapOptions = MapOptions(
zoom: 0,
viewMode: '2D',
);
AMap aMap = AMap('location', _mapOptions);
aMap.plugin(['AMap.Geolocation'], allowInterop(() {
Geolocation geolocation = Geolocation(GeoOptions());
aMap.addControl(geolocation);
geolocation.getCurrentPosition(allowInterop((status, result) {
if (status == 'complete') {
AMapLocation.customStreamController.add(Location(
latLng: LatLng(result.position.lat, result.position.lng),
country: result.addressComponent.country,
province: result.addressComponent.province,
city: result.addressComponent.city,
district: result.addressComponent.district,
street: result.addressComponent.street,
address: result.formattedAddress,
accuracy: 0.0,
).toJson());
} else {
AMapLocation.customStreamController.add(result.message);
}
}));
}));
});
return Future.value(true);
}