import 'dart:ui'; import 'package:get/get.dart'; import 'package:scence_map/controller.dart'; import 'package:cpnav/service/base.dart'; class PassTrackController extends GetxController { final mapController = Get.put(ScenceMapController()); String projCode; String projType; late final GetServices service; PassTrackController(this.projCode, this.projType); @override void onInit() { super.onInit(); service = GetServices(projCode: projCode, projType: projType); loadProject(); loadSideLine(); loadBindDevice(); } loadBindDevice() async { var binddevices = await service.getDeviceBind(); for (var device in binddevices) { var dev = DeviceItem.fromJson(device); mapController.deviceList[dev.TID] = dev; } } loadCoorTrans() async {} loadProject() async {} loadSideLine() async { var data = await service.getSideLine(); double maxX = -double.infinity; double maxY = -double.infinity; double minX = double.infinity; double minY = double.infinity; var sideLineData = data as Map; sideLineData.forEach((group, items) { for (var item in items) { SideLineItem sideLineItem = SideLineItem.fromJson(item); var sideLineList = mapController.sideLinListeMap[group]; if (sideLineList == null) { sideLineList = []; mapController.sideLinListeMap[group] = sideLineList; } sideLineList.add(sideLineItem); if (sideLineItem.x > maxX) { maxX = sideLineItem.x; } if (sideLineItem.y > maxY) { maxY = sideLineItem.y; } if (sideLineItem.x < minX) { minX = sideLineItem.x; } if (sideLineItem.y < minY) { minY = sideLineItem.y; } } }); if (maxX != -double.infinity && maxY != -double.infinity && minX != double.infinity && minY != double.infinity) { mapController.centerXY = Offset((maxX + minX) / 2, (maxY + minY) / 2); } } }