location_convert_marker_util.dart 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import 'package:flutter_map/flutter_map.dart';
  2. import 'package:location/data/bean/user_info.dart';
  3. import 'package:location/data/consts/constants.dart';
  4. class Location2MarkerUtil {
  5. Location2MarkerUtil._();
  6. static Marker userInfo2Marker(UserInfo e, bool isSelected) {
  7. return Marker(
  8. id: e.id,
  9. markerName: e.getUserNickName(),
  10. longitude: e.lastLocation.value?.longitude,
  11. latitude: e.lastLocation.value?.latitude,
  12. markerType: e.id == Constants.mineLocationId
  13. ? MarkerType.mine
  14. : MarkerType.friend,
  15. isSelected: isSelected,
  16. );
  17. }
  18. static List<Marker> userInfoList2MarkerList(
  19. List<UserInfo> list, UserInfo? selectedFriend) {
  20. List<Marker> markers = [];
  21. for (var e in list) {
  22. if ((e.isMine == true || e.blockedMe != true) &&
  23. e.lastLocation.value?.longitude != null &&
  24. e.lastLocation.value?.latitude != null) {
  25. markers.add(userInfo2Marker(e, e.id == selectedFriend?.id));
  26. }
  27. }
  28. return markers;
  29. // return list
  30. // .where((e) => e.blockedHim != true)
  31. // .map((e) => userInfo2Marker(e, e.id == selectedFriend?.id))
  32. // .toList();
  33. }
  34. }