fixed popup buttons added location stream and center button
This commit is contained in:
@ -3,6 +3,7 @@ import 'dart:typed_data';
|
||||
import 'package:camera_camera/camera_camera.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -756,9 +757,17 @@ class DestinationController extends GetxController {
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
ever(locationController.currentPosition, handleLocationUpdate);
|
||||
startGame();
|
||||
super.onInit();
|
||||
locationController.locationMarkerPositionStream.listen(
|
||||
(locationMarkerPosition) {
|
||||
if (locationMarkerPosition != null) {
|
||||
handleLocationUpdate(locationMarkerPosition);
|
||||
}
|
||||
}, onError: (err) {
|
||||
print("Error: $err");
|
||||
});
|
||||
|
||||
startGame();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -766,7 +775,7 @@ class DestinationController extends GetxController {
|
||||
locationController.stopPositionStream();
|
||||
}
|
||||
|
||||
void handleLocationUpdate(Position? position) async {
|
||||
void handleLocationUpdate(LocationMarkerPosition? position) async {
|
||||
try {
|
||||
if (position != null) {
|
||||
if (distanceToStart() >= 1000) {
|
||||
@ -795,7 +804,7 @@ class DestinationController extends GetxController {
|
||||
}
|
||||
} finally {
|
||||
if (position != null &&
|
||||
(position.latitude != 0 || position.longitude != 0)) {
|
||||
(position.latitude != 0 && position.longitude != 0)) {
|
||||
currentLat = position.latitude;
|
||||
currentLon = position.longitude;
|
||||
}
|
||||
@ -912,13 +921,13 @@ class DestinationController extends GetxController {
|
||||
indexController.currentBound.clear();
|
||||
indexController.currentBound.add(bnds);
|
||||
indexController.loadLocationsBound();
|
||||
centerMapToCurrentLocation();
|
||||
}
|
||||
});
|
||||
centerMapToCurrentLocation();
|
||||
}
|
||||
|
||||
void centerMapToCurrentLocation() {
|
||||
print("center is ${currentLat}, ${currentLon}");
|
||||
print("center is ${currentLon}, ${currentLon}");
|
||||
if (currentLat != 0 || currentLon != 0) {
|
||||
indexController.mapController.move(LatLng(currentLat, currentLon), 17.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user