Skip to content

Commit

Permalink
release: 1.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kuloud committed Aug 25, 2024
1 parent 74e60b2 commit 8c59ec2
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 118 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
## 1.0.11
2024-08-25
* 升级amap iOS sdk版本 10.0.900 | 2024-08-23
* code lint

## 1.0.10
2024-08-25
* 移除extension实现机制
* 添加 getMapContentApprovalNumber / getSatelliteImageApprovalNumber(参见example#ShowMapPage)
* 添加 InfoWindowAdapter(参见example#CustomInfoWindowDemoPage),结合 infoWindowEnable 和 BaseInfoWindowAdapter 自行实现具体逻辑
* permission_handler 11.3.0 -> 11.3.1

## 1.0.9
2024-08-24
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

| | Android | iOS |
| ----------- | -------------------------- | -------- |
| **AMapSDK** | 10.0.800_loc6.4.5_sea9.7.2 | 10.0.800 |
| **AMapSDK** | 10.0.800_loc6.4.5_sea9.7.2 | 10.0.900 |
| **Support** | SDK 16+ | 12.0+ |

本插件基于 amap_flutter_map 3.0.0 进行二开的原因:
Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:lints/recommended.yaml
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- AMap3DMap (10.0.800):
- AMap3DMap (10.0.900):
- AMapFoundation (>= 1.8.0)
- amap_map (1.0.8):
- AMap3DMap
Expand Down Expand Up @@ -28,7 +28,7 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/permission_handler_apple/ios"

SPEC CHECKSUMS:
AMap3DMap: 6761e0381f517978312e4f795ce77b2b9f6781a6
AMap3DMap: 220e48934bc6553a15251c8c86f581a802787506
amap_map: 5be213f350872f6ea406be964031572ab9a0d6e1
AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Expand Down
4 changes: 2 additions & 2 deletions example/lib/widgets/amap_radio_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class _AMapRadioGroupState<T> extends State<AMapRadioGroup<T>> {
@override
void initState() {
super.initState();
_groupValue = (widget.groupValue ?? null) as T?;
_groupValue = (widget.groupValue);
}

@override
Widget build(BuildContext context) {
List<Widget> radioList = <Widget>[];
_groupValue = (widget.groupValue ?? null) as T?;
_groupValue = (widget.groupValue);
Widget _myRadio(String label, dynamic radioValue) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/amap_initializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

part of amap_map;
part of '../amap_map.dart';

class AMapInitializer {
static AMapApiKey? _apiKey;
Expand Down
47 changes: 23 additions & 24 deletions lib/src/amap_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,

part of amap_map;
part of '../amap_map.dart';

typedef void MapCreatedCallback(AMapController controller);
typedef MapCreatedCallback = void Function(AMapController controller);

///用于展示高德地图的Widget
class AMapWidget extends StatefulWidget {
Expand Down Expand Up @@ -124,7 +124,7 @@ class AMapWidget extends StatefulWidget {
///
/// [AssertionError] will be thrown if [initialCameraPosition] is null;
const AMapWidget(
{Key? key,
{super.key,
this.initialCameraPosition =
const CameraPosition(target: LatLng(39.909187, 116.397451), zoom: 10),
this.mapType = MapType.normal,
Expand Down Expand Up @@ -157,8 +157,7 @@ class AMapWidget extends StatefulWidget {
this.infoWindowAdapter,
this.logoPosition,
this.logoBottomMargin,
this.logoLeftMargin})
: super(key: key);
this.logoLeftMargin});

///
@override
Expand All @@ -169,7 +168,7 @@ class _MapState extends State<AMapWidget> {
Map<String, Marker> _markers = <String, Marker>{};
Map<String, Polyline> _polylines = <String, Polyline>{};
Map<String, Polygon> _polygons = <String, Polygon>{};
Map<String, Widget?> _infoWindows = <String, Widget?>{};
final Map<String, Widget?> _infoWindows = <String, Widget?>{};

final Completer<AMapController> _controller = Completer<AMapController>();
late _AMapOptions _mapOptions;
Expand Down Expand Up @@ -244,38 +243,38 @@ class _MapState extends State<AMapWidget> {
);
_controller.complete(controller);

final MapCreatedCallback? _onMapCreated = widget.onMapCreated;
if (_onMapCreated != null) {
_onMapCreated(controller);
final MapCreatedCallback? onMapCreated = widget.onMapCreated;
if (onMapCreated != null) {
onMapCreated(controller);
}
}

void onMarkerTap(String markerId) {
final Marker? _marker = _markers[markerId];
if (_marker != null) {
final ArgumentCallback<String>? _onTap = _marker.onTap;
if (_onTap != null) {
_onTap(markerId);
final Marker? marker = _markers[markerId];
if (marker != null) {
final ArgumentCallback<String>? onTap = marker.onTap;
if (onTap != null) {
onTap(markerId);
}
}
}

void onMarkerDragEnd(String markerId, LatLng position) {
final Marker? _marker = _markers[markerId];
if (_marker != null) {
final MarkerDragEndCallback? _onDragEnd = _marker.onDragEnd;
if (_onDragEnd != null) {
_onDragEnd(markerId, position);
final Marker? marker = _markers[markerId];
if (marker != null) {
final MarkerDragEndCallback? onDragEnd = marker.onDragEnd;
if (onDragEnd != null) {
onDragEnd(markerId, position);
}
}
}

void onPolylineTap(String polylineId) {
final Polyline? _polyline = _polylines[polylineId];
if (_polyline != null) {
final ArgumentCallback<String>? _onTap = _polyline.onTap;
if (_onTap != null) {
_onTap(polylineId);
final Polyline? polyline = _polylines[polylineId];
if (polyline != null) {
final ArgumentCallback<String>? onTap = polyline.onTap;
if (onTap != null) {
onTap(polylineId);
}
}
}
Expand Down
21 changes: 9 additions & 12 deletions lib/src/core/map_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,27 @@ class MapEvent<T> {

///定位回调接口
class LocationChangedEvent extends MapEvent<AMapLocation> {
LocationChangedEvent(int mapId, AMapLocation value) : super(mapId, value);
LocationChangedEvent(super.mapId, super.value);
}

///地图移动回调
class CameraPositionMoveEvent extends MapEvent<CameraPosition> {
CameraPositionMoveEvent(int mapId, CameraPosition value)
: super(mapId, value);
CameraPositionMoveEvent(super.mapId, super.value);
}

///地图移动结束回调
class CameraPositionMoveEndEvent extends MapEvent<CameraPosition> {
CameraPositionMoveEndEvent(int mapId, CameraPosition value)
: super(mapId, value);
CameraPositionMoveEndEvent(super.mapId, super.value);
}

///点击地图回调
class MapTapEvent extends MapEvent<LatLng> {
MapTapEvent(int mapId, LatLng value) : super(mapId, value);
MapTapEvent(super.mapId, super.value);
}

///长按地图回调
class MapLongPressEvent extends MapEvent<LatLng> {
MapLongPressEvent(int mapId, LatLng value) : super(mapId, value);
MapLongPressEvent(super.mapId, super.value);
}

/// 带位置回调的地图事件
Expand All @@ -57,21 +55,20 @@ class _PositionedMapEvent<T> extends MapEvent<T> {

/// [Marker] 的点击事件
class MarkerTapEvent extends MapEvent<String> {
MarkerTapEvent(int mapId, String markerId) : super(mapId, markerId);
MarkerTapEvent(super.mapId, super.markerId);
}

/// [Marker] 的拖拽结束事件,附带拖拽结束时的位置信息[LatLng].
class MarkerDragEndEvent extends _PositionedMapEvent<String> {
MarkerDragEndEvent(int mapId, LatLng position, String markerId)
: super(mapId, position, markerId);
MarkerDragEndEvent(super.mapId, super.position, super.markerId);
}

/// [Polyline] 的点击事件
class PolylineTapEvent extends MapEvent<String> {
PolylineTapEvent(int mapId, String polylineId) : super(mapId, polylineId);
PolylineTapEvent(super.mapId, super.polylineId);
}

/// Poi点击事件
class MapPoiTouchEvent extends MapEvent<AMapPoi> {
MapPoiTouchEvent(int mapId, AMapPoi poi) : super(mapId, poi);
MapPoiTouchEvent(super.mapId, super.poi);
}
8 changes: 4 additions & 4 deletions lib/src/core/method_channel_amap_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
_mapEventStreamController.add(LocationChangedEvent(
mapId, AMapLocation.fromMap(call.arguments['location'])!));
} catch (e) {
print("location#changed error=======>" + e.toString());
print("location#changed error=======>$e");
}
break;

Expand All @@ -191,15 +191,15 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
_mapEventStreamController.add(CameraPositionMoveEvent(
mapId, CameraPosition.fromMap(call.arguments['position'])!));
} catch (e) {
print("camera#onMove error===>" + e.toString());
print("camera#onMove error===>$e");
}
break;
case 'camera#onMoveEnd':
try {
_mapEventStreamController.add(CameraPositionMoveEndEvent(
mapId, CameraPosition.fromMap(call.arguments['position'])!));
} catch (e) {
print("camera#onMoveEnd error===>" + e.toString());
print("camera#onMoveEnd error===>$e");
}
break;
case 'map#onTap':
Expand Down Expand Up @@ -232,7 +232,7 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform {
_mapEventStreamController.add(MapPoiTouchEvent(
mapId, AMapPoi.fromJson(call.arguments['poi'])!));
} catch (e) {
print('map#onPoiTouched error===>' + e.toString());
print('map#onPoiTouched error===>$e');
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/base_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BaseOverlay {
String get id => _id;

BaseOverlay() {
this._id = this.hashCode.toString();
_id = hashCode.toString();
}

void setIdForCopy(String copyId) => _id = copyId;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/types/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CameraPosition {
///
/// 主要在插件内部使用
static CameraPosition? fromMap(dynamic json) {
if (json == null || !(json is Map<dynamic, dynamic>)) {
if (json == null || json is! Map<dynamic, dynamic>) {
return null;
}
final LatLng? target = LatLng.fromJson(json['target']);
Expand Down
7 changes: 4 additions & 3 deletions lib/src/types/marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:x_amap_base/x_amap_base.dart';
import 'bitmap.dart';

/// Marker拖动回调
typedef void MarkerDragEndCallback(String id, LatLng endPosition);
typedef MarkerDragEndCallback = void Function(String id, LatLng endPosition);

///Marker的气泡
///
Expand Down Expand Up @@ -91,11 +91,11 @@ class Marker extends BaseOverlay {
this.zIndex = 0.0,
this.onTap,
this.onDragEnd,
}) : this.alpha =
}) : alpha =
// ignore: unnecessary_null_comparison
(alpha != null ? (alpha < 0 ? 0 : (alpha > 1 ? 1 : alpha)) : alpha),
// ignore: unnecessary_null_comparison
this.anchor = (anchor == null
anchor = (anchor == null
? Offset(0.5, 1.0)
: ((anchor.dx < 0 ||
anchor.dx > 1 ||
Expand Down Expand Up @@ -182,6 +182,7 @@ class Marker extends BaseOverlay {
return copyMark;
}

@override
Marker clone() => copyWith();

@override
Expand Down
10 changes: 0 additions & 10 deletions lib/src/types/marker_updates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ import 'types.dart';
class MarkerUpdates {
/// 根据之前的marker列表[previous]和当前的marker列表[current]创建[MakerUpdates].
MarkerUpdates.from(Set<Marker> previous, Set<Marker> current) {
// ignore: unnecessary_null_comparison
if (previous == null) {
previous = Set<Marker>.identity();
}

// ignore: unnecessary_null_comparison
if (current == null) {
current = Set<Marker>.identity();
}

final Map<String, Marker> previousMarkers = keyByMarkerId(previous);
final Map<String, Marker> currentMarkers = keyByMarkerId(current);

Expand Down
1 change: 1 addition & 0 deletions lib/src/types/polygon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Polygon extends BaseOverlay {
return copyPolyline;
}

@override
Polygon clone() => copyWith();

/// 转换成可以序列化的map
Expand Down
22 changes: 6 additions & 16 deletions lib/src/types/polygon_updates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ import 'types.dart';
class PolygonUpdates {
/// 通过Polygon的前后更新集合构造一个PolygonUpdates
PolygonUpdates.from(Set<Polygon> previous, Set<Polygon> current) {
// ignore: unnecessary_null_comparison
if (previous == null) {
previous = Set<Polygon>.identity();
}

// ignore: unnecessary_null_comparison
if (current == null) {
current = Set<Polygon>.identity();
}

final Map<String, Polygon> previousPolygons = keyByPolygonId(previous);
final Map<String, Polygon> currentPolygons = keyByPolygonId(current);

Expand All @@ -29,10 +19,10 @@ class PolygonUpdates {
return currentPolygons[id]!;
}

final Set<String> _polygonIdsToRemove =
final Set<String> tempPolygonIdsToRemove =
prevPolygonIds.difference(currentPolygonIds);

final Set<Polygon> _polygonsToAdd = currentPolygonIds
final Set<Polygon> tempPolygonsToAdd = currentPolygonIds
.difference(prevPolygonIds)
.map(idToCurrentPolygon)
.toSet();
Expand All @@ -42,15 +32,15 @@ class PolygonUpdates {
return current != previous;
}

final Set<Polygon> _polygonsToChange = currentPolygonIds
final Set<Polygon> tempPolygonsToChange = currentPolygonIds
.intersection(prevPolygonIds)
.map(idToCurrentPolygon)
.where(hasChanged)
.toSet();

polygonsToAdd = _polygonsToAdd;
polygonIdsToRemove = _polygonIdsToRemove;
polygonsToChange = _polygonsToChange;
polygonsToAdd = tempPolygonsToAdd;
polygonIdsToRemove = tempPolygonIdsToRemove;
polygonsToChange = tempPolygonsToChange;
}

/// 想要添加的polygon对象集合.
Expand Down
Loading

0 comments on commit 8c59ec2

Please sign in to comment.