poi.dart
908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
part of csp_amap_flutter_base;
///poi
class AMapPoi {
/// 唯一标识符
final String? id;
/// POI的名称
final String? name;
/// 经纬度
final LatLng? latLng;
AMapPoi({
this.id,
this.name,
this.latLng,
});
dynamic toJson() {
final Map<String, dynamic> json = <String, dynamic>{};
void addIfPresent(String fieldName, dynamic value) {
if (value != null) {
json[fieldName] = value;
}
}
addIfPresent('id', id);
addIfPresent('name', name);
addIfPresent('latLng', latLng?.toJson());
return json;
}
static AMapPoi? fromJson(dynamic json) {
if (null == json) {
return null;
}
return AMapPoi(
id: json['id'],
name: json['name'],
latLng: LatLng.fromJson(json['latLng'])!,
);
}
@override
String toString() {
return 'TouchPOI(id: $id, name: $name, latlng: $latLng)';
}
}