diff --git a/assets/icons/chicken_map_marker.svg b/assets/icons/chicken_map_marker.svg new file mode 100644 index 0000000..2099322 --- /dev/null +++ b/assets/icons/chicken_map_marker.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/chicken_marker_location.svg b/assets/icons/chicken_marker_location.svg deleted file mode 100644 index 6d79658..0000000 --- a/assets/icons/chicken_marker_location.svg +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/assets/vec/chicken_map_marker.svg.vec b/assets/vec/chicken_map_marker.svg.vec new file mode 100644 index 0000000..4ea6f27 Binary files /dev/null and b/assets/vec/chicken_map_marker.svg.vec differ diff --git a/packages/core/lib/presentation/common/assets.gen.dart b/packages/core/lib/presentation/common/assets.gen.dart index dba8dfe..b349f7c 100644 --- a/packages/core/lib/presentation/common/assets.gen.dart +++ b/packages/core/lib/presentation/common/assets.gen.dart @@ -76,6 +76,9 @@ class $AssetsIconsGen { /// File path: assets/icons/chicken.svg SvgGenImage get chicken => const SvgGenImage('assets/icons/chicken.svg'); + /// File path: assets/icons/chicken_map_marker.svg + SvgGenImage get chickenMapMarker => const SvgGenImage('assets/icons/chicken_map_marker.svg'); + /// File path: assets/icons/clipboard_eye.svg SvgGenImage get clipboardEye => const SvgGenImage('assets/icons/clipboard_eye.svg'); @@ -291,6 +294,7 @@ class $AssetsIconsGen { check, checkSquare, chicken, + chickenMapMarker, clipboardEye, clipboardTask, clock, @@ -437,6 +441,9 @@ class $AssetsVecGen { /// File path: assets/vec/chicken.svg.vec SvgGenImage get chickenSvg => const SvgGenImage.vec('assets/vec/chicken.svg.vec'); + /// File path: assets/vec/chicken_map_marker.svg.vec + SvgGenImage get chickenMapMarkerSvg => const SvgGenImage.vec('assets/vec/chicken_map_marker.svg.vec'); + /// File path: assets/vec/clipboard_eye.svg.vec SvgGenImage get clipboardEyeSvg => const SvgGenImage.vec('assets/vec/clipboard_eye.svg.vec'); @@ -652,6 +659,7 @@ class $AssetsVecGen { checkSvg, checkSquareSvg, chickenSvg, + chickenMapMarkerSvg, clipboardEyeSvg, clipboardTaskSvg, clockSvg, diff --git a/packages/inspection/lib/presentation/pages/inspection_map/logic.dart b/packages/inspection/lib/presentation/pages/inspection_map/logic.dart index ede317b..39ba16a 100644 --- a/packages/inspection/lib/presentation/pages/inspection_map/logic.dart +++ b/packages/inspection/lib/presentation/pages/inspection_map/logic.dart @@ -19,6 +19,7 @@ class InspectionMapLogic extends GetxController with GetTickerProviderStateMixin RxList markers = [].obs; + Timer? _debounceTimer; RxBool isLoading = false.obs; RxBool isSelectedDetailsLocation = false.obs; @@ -119,25 +120,59 @@ class InspectionMapLogic extends GetxController with GetTickerProviderStateMixin void debouncedUpdateVisibleMarkers({required LatLng center, required double zoom}) { _debounceTimer?.cancel(); _debounceTimer = Timer(const Duration(milliseconds: 300), () { - var raduis = getVisibleRadiusKm( + final radius = getVisibleRadiusKm( zoom: zoom, screenWidthPx: Get.width.toDouble(), latitude: center.latitude, ); + final filtered = filterNearbyMarkers( allPoultryLocation.value.data ?? [], center.latitude, center.longitude, - raduis * 1000, // Radius in meters - ); - markers.assignAll( - filtered.map( - (e) => Marker( - point: LatLng(e.lat ?? 0, e.long ?? 0), - child: Icon(Icons.location_on, color: Colors.red), - ), - ), + radius * 1000, ); + + final visibleBounds = animatedMapController.mapController.camera.visibleBounds; + final isZoomedIn = zoom > 17; + + final updatedMarkers = filtered.map((location) { + final point = LatLng(location.lat ?? 0, location.long ?? 0); + final isVisible = visibleBounds.contains(point); + + return Marker( + point: point, + width: isZoomedIn && isVisible ? 180.w : 40.h, + height: isZoomedIn && isVisible ? 50.h : 50.h, + child: isZoomedIn && isVisible + ? Container( + height: 30.h, + padding: EdgeInsets.all(5.r), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15.r), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.1), + blurRadius: 5, + offset: const Offset(0, 2), + ), + ], + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 8, + children: [ + Assets.vec.chickenMapMarkerSvg.svg(width: 24.w, height: 24.h), + Text(location.user?.fullname ?? '',style: AppFonts.yekan12,), + ], + ), + ) + : Assets.vec.chickenMapMarkerSvg.svg(width: 24.w, height: 24.h), + ); + }).toList(); + + markers.value = updatedMarkers; }); } diff --git a/packages/inspection/lib/presentation/pages/inspection_map/view.dart b/packages/inspection/lib/presentation/pages/inspection_map/view.dart index 1d3734f..9c5a75e 100644 --- a/packages/inspection/lib/presentation/pages/inspection_map/view.dart +++ b/packages/inspection/lib/presentation/pages/inspection_map/view.dart @@ -43,7 +43,11 @@ class InspectionMapPage extends GetView { ), initialZoom: 15, onPositionChanged: (camera, hasGesture) { - controller.debouncedUpdateVisibleMarkers(center: camera.center,zoom: camera.zoom); + wLog(camera.zoom); + controller.debouncedUpdateVisibleMarkers( + center: camera.center, + zoom: camera.zoom, + ); }, ), @@ -52,29 +56,35 @@ class InspectionMapPage extends GetView { urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', userAgentPackageName: 'ir.mnpc.rasadyar', ), - MarkerClusterLayerWidget( - options: MarkerClusterLayerOptions( - maxClusterRadius: 80, - size: const Size(40, 40), - alignment: Alignment.center, - padding: const EdgeInsets.all(50), - maxZoom: 15, - markers: controller.markers, - builder: (context, markers) { - return Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: Colors.blue, - ), - child: Center( - child: Text( - markers.length.toString(), - style: const TextStyle(color: Colors.white), - ), - ), - ); - }, - ), + + ObxValue( + (markers) { + return MarkerClusterLayerWidget( + options: MarkerClusterLayerOptions( + maxClusterRadius: 80, + size: const Size(40, 40), + alignment: Alignment.center, + padding: const EdgeInsets.all(50), + maxZoom: 15, + markers: markers.value, + builder: (context, clusterMarkers) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Colors.blue, + ), + child: Center( + child: Text( + clusterMarkers.length.toString(), + style: const TextStyle(color: Colors.white), + ), + ), + ); + }, + ), + ); + }, + controller.markers, ), ], );