location_result_entity_helper.dart 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import 'package:amap_location/location_result_entity.dart';
  2. locationResultEntityFromJson(
  3. LocationResultEntity data, Map<String, dynamic> json) {
  4. if (json['altitude'] != null) {
  5. data.altitude = json['altitude']?.toInt();
  6. }
  7. if (json['speed'] != null) {
  8. data.speed = json['speed']?.toInt();
  9. }
  10. if (json['bearing'] != null) {
  11. data.bearing = json['bearing']?.toInt();
  12. }
  13. if (json['citycode'] != null) {
  14. data.citycode = json['citycode']?.toString();
  15. }
  16. if (json['adcode'] != null) {
  17. data.adcode = json['adcode']?.toString();
  18. }
  19. if (json['country'] != null) {
  20. data.country = json['country']?.toString();
  21. }
  22. if (json['province'] != null) {
  23. data.province = json['province']?.toString();
  24. }
  25. if (json['city'] != null) {
  26. data.city = json['city']?.toString();
  27. }
  28. if (json['district'] != null) {
  29. data.district = json['district']?.toString();
  30. }
  31. if (json['road'] != null) {
  32. data.road = json['road']?.toString();
  33. }
  34. if (json['street'] != null) {
  35. data.street = json['street']?.toString();
  36. }
  37. if (json['number'] != null) {
  38. data.number = json['number']?.toString();
  39. }
  40. if (json['poiname'] != null) {
  41. data.poiname = json['poiname']?.toString();
  42. }
  43. if (json['errorCode'] != null) {
  44. data.errorCode = json['errorCode']?.toInt();
  45. }
  46. if (json['errorInfo'] != null) {
  47. data.errorInfo = json['errorInfo']?.toString();
  48. }
  49. if (json['locationType'] != null) {
  50. data.locationType = json['locationType']?.toInt();
  51. }
  52. if (json['locationDetail'] != null) {
  53. data.locationDetail = json['locationDetail']?.toString();
  54. }
  55. if (json['aoiname'] != null) {
  56. data.aoiname = json['aoiname']?.toString();
  57. }
  58. if (json['address'] != null) {
  59. data.address = json['address']?.toString();
  60. }
  61. if (json['poiid'] != null) {
  62. data.poiid = json['poiid']?.toString();
  63. }
  64. if (json['floor'] != null) {
  65. data.floor = json['floor']?.toString();
  66. }
  67. if (json['description'] != null) {
  68. data.description = json['description']?.toString();
  69. }
  70. if (json['time'] != null) {
  71. data.time = json['time']?.toInt();
  72. }
  73. if (json['provider'] != null) {
  74. data.provider = json['provider']?.toString();
  75. }
  76. if (json['lon'] != null) {
  77. data.lon = json['lon']?.toDouble();
  78. }
  79. if (json['lat'] != null) {
  80. data.lat = json['lat']?.toDouble();
  81. }
  82. if (json['accuracy'] != null) {
  83. data.accuracy = json['accuracy']?.toInt();
  84. }
  85. if (json['isOffset'] != null) {
  86. data.isOffset = json['isOffset'];
  87. }
  88. if (json['isFixLastLocation'] != null) {
  89. data.isFixLastLocation = json['isFixLastLocation'];
  90. }
  91. if (json['coordType'] != null) {
  92. data.coordType = json['coordType']?.toString();
  93. }
  94. return data;
  95. }
  96. Map<String, dynamic> locationResultEntityToJson(LocationResultEntity entity) {
  97. final Map<String, dynamic> data = new Map<String, dynamic>();
  98. data['altitude'] = entity.altitude;
  99. data['speed'] = entity.speed;
  100. data['bearing'] = entity.bearing;
  101. data['citycode'] = entity.citycode;
  102. data['adcode'] = entity.adcode;
  103. data['country'] = entity.country;
  104. data['province'] = entity.province;
  105. data['city'] = entity.city;
  106. data['district'] = entity.district;
  107. data['road'] = entity.road;
  108. data['street'] = entity.street;
  109. data['number'] = entity.number;
  110. data['poiname'] = entity.poiname;
  111. data['errorCode'] = entity.errorCode;
  112. data['errorInfo'] = entity.errorInfo;
  113. data['locationType'] = entity.locationType;
  114. data['locationDetail'] = entity.locationDetail;
  115. data['aoiname'] = entity.aoiname;
  116. data['address'] = entity.address;
  117. data['poiid'] = entity.poiid;
  118. data['floor'] = entity.floor;
  119. data['description'] = entity.description;
  120. data['time'] = entity.time;
  121. data['provider'] = entity.provider;
  122. data['lon'] = entity.lon;
  123. data['lat'] = entity.lat;
  124. data['accuracy'] = entity.accuracy;
  125. data['isOffset'] = entity.isOffset;
  126. data['isFixLastLocation'] = entity.isFixLastLocation;
  127. data['coordType'] = entity.coordType;
  128. return data;
  129. }