|
|
|
|
@ -17,8 +17,9 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
|
import 'package:google_maps_place_picker/google_maps_place_picker.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/app_map/google_huawei_map.dart';
|
|
|
|
|
import 'location_page.dart';
|
|
|
|
|
import 'package:geolocator/geolocator.dart';
|
|
|
|
|
|
|
|
|
|
class NewHomeHealthCareStepTowPage extends StatefulWidget {
|
|
|
|
|
final Function(PickResult) onPick;
|
|
|
|
|
@ -39,35 +40,47 @@ class _NewHomeHealthCareStepTowPageState extends State<NewHomeHealthCareStepTowP
|
|
|
|
|
double longitude = 0;
|
|
|
|
|
AddressInfo _selectedAddress;
|
|
|
|
|
bool showCurrentLocation = false;
|
|
|
|
|
Completer<GoogleMapController> _controller = Completer();
|
|
|
|
|
GoogleMapController googleMapController;
|
|
|
|
|
final Set<Marker> markers = new Set();
|
|
|
|
|
AppMap appMap;
|
|
|
|
|
static CameraPosition _kGooglePlex = CameraPosition(
|
|
|
|
|
target: LatLng(37.42796133580664, -122.085749655962),
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
);
|
|
|
|
|
LatLng currentPostion;
|
|
|
|
|
Completer<GoogleMapController> mapController = Completer();
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
if (widget.patientERInsertPresOrderRequestModel.latitude == null) {
|
|
|
|
|
setLatitudeAndLongitude();
|
|
|
|
|
} else {
|
|
|
|
|
latitude = widget.patientERInsertPresOrderRequestModel.latitude;
|
|
|
|
|
longitude = widget.patientERInsertPresOrderRequestModel.longitude;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
markers.clear();
|
|
|
|
|
markers.add(
|
|
|
|
|
Marker(
|
|
|
|
|
markerId: MarkerId(
|
|
|
|
|
latitude.hashCode.toString(),
|
|
|
|
|
),
|
|
|
|
|
position: LatLng(latitude, longitude)),
|
|
|
|
|
appMap = AppMap(
|
|
|
|
|
_kGooglePlex.toMap(),
|
|
|
|
|
onCameraMove: (camera) {
|
|
|
|
|
_updatePosition(camera);
|
|
|
|
|
},
|
|
|
|
|
onMapCreated: () {
|
|
|
|
|
goToCurrentLocation();
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
// if (widget.patientERInsertPresOrderRequestModel.latitude == null) {
|
|
|
|
|
// setLatitudeAndLongitude();
|
|
|
|
|
// } else {
|
|
|
|
|
// latitude = widget.patientERInsertPresOrderRequestModel.latitude;
|
|
|
|
|
// longitude = widget.patientERInsertPresOrderRequestModel.longitude;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// markers.clear();
|
|
|
|
|
// markers.add(
|
|
|
|
|
// Marker(
|
|
|
|
|
// markerId: MarkerId(
|
|
|
|
|
// latitude.hashCode.toString(),
|
|
|
|
|
// ),
|
|
|
|
|
// position: LatLng(latitude, longitude)),
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
// _kGooglePlex = CameraPosition(
|
|
|
|
|
// target: LatLng(latitude, longitude),
|
|
|
|
|
// zoom: 14.4746,
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
_kGooglePlex = CameraPosition(
|
|
|
|
|
target: LatLng(latitude, longitude),
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
);
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -87,9 +100,21 @@ class _NewHomeHealthCareStepTowPageState extends State<NewHomeHealthCareStepTowP
|
|
|
|
|
|
|
|
|
|
latitude = double.parse(latLongArr[0]);
|
|
|
|
|
longitude = double.parse(latLongArr[1]);
|
|
|
|
|
currentPostion = LatLng(latitude, longitude);
|
|
|
|
|
setMap();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setMap() {
|
|
|
|
|
setState(() {
|
|
|
|
|
_kGooglePlex = CameraPosition(
|
|
|
|
|
target: currentPostion,
|
|
|
|
|
zoom: 14.4746,
|
|
|
|
|
);
|
|
|
|
|
appMap.moveTo(cameraPostion: _kGooglePlex);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
|
@ -168,22 +193,35 @@ class _NewHomeHealthCareStepTowPageState extends State<NewHomeHealthCareStepTowP
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
// Expanded(
|
|
|
|
|
// child: Stack(
|
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
|
// children: [
|
|
|
|
|
// GoogleMap(
|
|
|
|
|
// mapType: MapType.normal,
|
|
|
|
|
// zoomControlsEnabled: false,
|
|
|
|
|
// myLocationButtonEnabled: true,
|
|
|
|
|
// myLocationEnabled: true,
|
|
|
|
|
// initialCameraPosition: _kGooglePlex,
|
|
|
|
|
// onCameraMove: ((_position) => _updatePosition(_position)),
|
|
|
|
|
// onMapCreated: (GoogleMapController controller) {
|
|
|
|
|
// googleMapController = controller;
|
|
|
|
|
// _controller.complete(controller);
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// Icon(
|
|
|
|
|
// Icons.place,
|
|
|
|
|
// color: CustomColors.accentColor,
|
|
|
|
|
// size: 50,
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Stack(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
GoogleMap(
|
|
|
|
|
mapType: MapType.normal,
|
|
|
|
|
zoomControlsEnabled: false,
|
|
|
|
|
myLocationButtonEnabled: true,
|
|
|
|
|
myLocationEnabled: true,
|
|
|
|
|
initialCameraPosition: _kGooglePlex,
|
|
|
|
|
onCameraMove: ((_position) => _updatePosition(_position)),
|
|
|
|
|
onMapCreated: (GoogleMapController controller) {
|
|
|
|
|
googleMapController = controller;
|
|
|
|
|
_controller.complete(controller);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (appMap != null) appMap,
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.place,
|
|
|
|
|
color: CustomColors.accentColor,
|
|
|
|
|
@ -246,4 +284,27 @@ class _NewHomeHealthCareStepTowPageState extends State<NewHomeHealthCareStepTowP
|
|
|
|
|
else
|
|
|
|
|
return TranslationBase.of(context).selectAddress;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
goToCurrentLocation() {
|
|
|
|
|
Geolocator.getCurrentPosition().then((value) {
|
|
|
|
|
_selectedAddress = AddressInfo(latLong: '${value.latitude},${value.longitude}');
|
|
|
|
|
moveToLocation(LatLng(value.latitude, value.longitude));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
moveToLocation(LatLng location, {bool animate = true}) async {
|
|
|
|
|
await Future.delayed(Duration(milliseconds: 200));
|
|
|
|
|
_kGooglePlex = CameraPosition(
|
|
|
|
|
target: location,
|
|
|
|
|
zoom: 16.4746,
|
|
|
|
|
);
|
|
|
|
|
if (animate)
|
|
|
|
|
(await mapController.future).animateCamera(
|
|
|
|
|
CameraUpdate.newCameraPosition(_kGooglePlex),
|
|
|
|
|
);
|
|
|
|
|
else
|
|
|
|
|
(await mapController.future).moveCamera(
|
|
|
|
|
CameraUpdate.newCameraPosition(_kGooglePlex),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|