| 123456789101112131415161718192021222324252627282930313233343536 |
- import '../../flutter_map.dart';
- class PoiSearchBound {
- final LatLng? center; // 圆形范围中心点
- final int? radius; // 半径(米)
- final List<LatLng>? points; // 多边形点集
- /// 圆形范围构造
- PoiSearchBound.circle({
- required this.center,
- required this.radius,
- }) : points = null;
- /// 多边形范围构造
- PoiSearchBound.polygon({
- required this.points,
- }) : center = null,
- radius = null;
- /// 转 Map,用于传给 MethodChannel
- Map<String, dynamic> toJson() {
- if (center != null && radius != null) {
- return {
- 'type': 'circle',
- 'center': center!.toJson(),
- 'radius': radius,
- };
- } else if (points != null) {
- return {
- 'type': 'polygon',
- 'points': points!.map((e) => e.toJson()).toList(),
- };
- }
- throw Exception('Invalid PoiSearchBound: 必须是 circle 或 polygon');
- }
- }
|