Skip to content

Commit

Permalink
release: 1.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
kuloud committed Aug 25, 2024
1 parent 9c1509c commit 2a889eb
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 530 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.10
2024-08-25
* 移除extension实现机制
* 添加 getMapContentApprovalNumber / getSatelliteImageApprovalNumber(参见example#ShowMapPage)
* 添加 InfoWindowAdapter(参见example#CustomInfoWindowDemoPage),结合 infoWindowEnable 和 BaseInfoWindowAdapter 自行实现具体逻辑

## 1.0.9
2024-08-24
* 设置地图语言,支持中文、英文(按SDK描述:1、不能和自定义地图样式同时使用;2、英文状态只在标准地图生效)
Expand Down
17 changes: 1 addition & 16 deletions example/lib/data/demos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:amap_map_example/pages/interactive/map_ui_options.dart';
import 'package:amap_map_example/pages/map/change_map_lang.dart';
import 'package:amap_map_example/pages/map/limit_map_bounds.dart';
import 'package:amap_map_example/pages/map/map_my_location.dart';
import 'package:amap_map_example/pages/map/map_with_extension_page.dart';
import 'package:amap_map_example/pages/map/show_map_page.dart';
import 'package:amap_map_example/pages/overlays/custom_info_window.dart';
import 'package:amap_map_example/pages/overlays/marker_config.dart';
Expand All @@ -19,8 +18,7 @@ class DemoConfiguration {
final WidgetBuilder buildRoute;
}

List<Demo> allDemos() =>
mapDemos() + interactiveDemos() + overlayDemos() + extensionDemos();
List<Demo> allDemos() => mapDemos() + interactiveDemos() + overlayDemos();

List<Demo> mapDemos() {
return [
Expand Down Expand Up @@ -93,19 +91,6 @@ List<Demo> overlayDemos() {
];
}

List<Demo> extensionDemos() {
return [
Demo(
title: '辅助信息获取',
category: DemoCategory.extension,
subtitle: '获取审图号',
slug: 'extension-info',
configurations: [
DemoConfiguration(buildRoute: (context) => MapWithExtensionPage())
])
];
}

Map<String?, Demo> slugToDemo(BuildContext context) {
return LinkedHashMap<String?, Demo>.fromIterable(
allDemos(),
Expand Down
7 changes: 0 additions & 7 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ class _AMapDemoState extends State<AMapDemo>
category: DemoCategory.overlay,
demos: overlayDemos(),
)),
AnimatedCategoryItem(
startDelayFraction: 0.15,
controller: _animationController,
child: CategoryListItem(
category: DemoCategory.extension,
demos: extensionDemos(),
)),
],
),
);
Expand Down
81 changes: 0 additions & 81 deletions example/lib/pages/map/map_with_extension_page.dart

This file was deleted.

26 changes: 13 additions & 13 deletions example/lib/pages/map/show_map_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ class _ShowMapPageState extends State<ShowMapPage> {
void onMapCreated(AMapController controller) {
setState(() {
_mapController = controller;
// getApprovalNumber();
getApprovalNumber();
});
}

/// 获取审图号
void getApprovalNumber() async {
// //普通地图审图号
// String mapContentApprovalNumber =
// (await _mapController.getMapContentApprovalNumber())!;
// //卫星地图审图号
// String satelliteImageApprovalNumber =
// (await _mapController.getSatelliteImageApprovalNumber())!;
// setState(() {
// _approvalNumberWidget.add(Text(mapContentApprovalNumber));
// _approvalNumberWidget.add(Text(satelliteImageApprovalNumber));
// });
// print('地图审图号(普通地图): $mapContentApprovalNumber');
// print('地图审图号(卫星地图): $satelliteImageApprovalNumber');
//普通地图审图号
String mapContentApprovalNumber =
(await _mapController.getMapContentApprovalNumber());
//卫星地图审图号
String satelliteImageApprovalNumber =
(await _mapController.getSatelliteImageApprovalNumber());
setState(() {
_approvalNumberWidget.add(Text(mapContentApprovalNumber));
_approvalNumberWidget.add(Text(satelliteImageApprovalNumber));
});
print('地图审图号(普通地图): $mapContentApprovalNumber');
print('地图审图号(卫星地图): $satelliteImageApprovalNumber');
}
}
67 changes: 50 additions & 17 deletions example/lib/pages/overlays/custom_info_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ class _State extends State<CustomInfoWindowDemoPage> {
BitmapDescriptor? _markerIcon;
String? selectedMarkerId;
bool showInfoWindow = false;
AMapController? _controller;

final _infoWindowExtension = InfoWindowExtension(
infoWindow: Container(
color: Colors.lightBlue.shade400,
child: Text('info'),
),
option: InfoWindowOption(
latLng: mapCenter, offset: EdgeInsets.only(bottom: 32)));

Future<void> _onMapCreated(AMapController controller) async {}
Future<void> _onMapCreated(AMapController controller) async {
setState(() {
_controller = controller;
});
}

void _add() {
final int markerCount = _markers.length;
Expand Down Expand Up @@ -168,8 +165,8 @@ class _State extends State<CustomInfoWindowDemoPage> {
setState(() {
showInfoWindow = value;
_markers[selectedMarkerId!] = marker.copyWith(
// visibleParam: value,
);
visibleParam: value,
);
});
}

Expand All @@ -190,14 +187,10 @@ class _State extends State<CustomInfoWindowDemoPage> {
_markerIcon = BitmapDescriptor.fromIconPath('assets/location_marker.png');
}

_infoWindowExtension.option?.show =
_markers[selectedMarkerId] != null && showInfoWindow;
_infoWindowExtension.option?.latLng = _markers[selectedMarkerId]?.position;

final AMapWidget map = AMapWidget(
AMapWidget map = AMapWidget(
onMapCreated: _onMapCreated,
markers: Set<Marker>.of(_markers.values),
extensions: [_infoWindowExtension],
infoWindowAdapter: CustomInfoWindowAdapter(_controller, selectedMarkerId),
);
return Container(
height: MediaQuery.of(context).size.height,
Expand Down Expand Up @@ -293,3 +286,43 @@ class _State extends State<CustomInfoWindowDemoPage> {
);
}
}

class CustomInfoWindowAdapter extends BaseInfoWindowAdapter {
CustomInfoWindowAdapter(AMapController? controller, this.selectedMarkerId)
: super(controller);

final String? selectedMarkerId;

@override
Widget? buildInfoWindowContent(BuildContext context, Marker marker) {
if (marker.id != selectedMarkerId) {
return null;
}
return Container(
padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.0),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 4.0,
spreadRadius: 2.0,
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
marker.infoWindow.title ?? 'No Title',
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
marker.infoWindow.snippet ?? 'No Snippet',
),
],
),
);
}
}
15 changes: 1 addition & 14 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Demonstrates how to use the amap_map plugin.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=3.1.5 <4.0.0"
Expand All @@ -16,20 +16,10 @@ dependencies:
flutter_plugin_android_lifecycle: ^2.0.21

amap_map:
# When depending on this package from a real application you should use:
# amap_map: ^x.y.z
# See https://dart.dev/tools/pub/dependencies#version-constraints
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
path: ../
x_common: ^1.0.4
x_amap_base: ^1.0.3

# amap_map_extensions: ^0.0.1
# amap_map_extensions:
# path: ../../amap_map_extensions


dev_dependencies:
flutter_test:
sdk: flutter
Expand All @@ -39,7 +29,6 @@ dev_dependencies:

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
Expand All @@ -51,5 +40,3 @@ flutter:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg


1 change: 0 additions & 1 deletion lib/amap_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ export 'package:amap_map/src/types/types.dart';
part 'src/amap_initializer.dart';
part 'src/amap_controller.dart';
part 'src/amap_widget.dart';
part 'src/amap_loader.dart';
part 'src/utils/location_utils.dart';
20 changes: 11 additions & 9 deletions lib/src/amap_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,43 +55,37 @@ class AMapController {
_methodChannel
.onCameraMove(mapId: mapId)
.listen((CameraPositionMoveEvent e) {
_mapState._extensions.values.forEach((ext) => ext.onCameraMove(e.value));
_mapState.widget.onCameraMove?.call(e.value);
if (_mapState.widget.infoWindowAdapter != null) {
_mapState.updateMarkers();
}
});

_methodChannel
.onCameraMoveEnd(mapId: mapId)
.listen((CameraPositionMoveEndEvent e) {
_mapState._extensions.values
.forEach((ext) => ext.onCameraMoveEnd(e.value));
_mapState.widget.onCameraMoveEnd?.call(e.value);
});
_methodChannel
.onMapTap(mapId: mapId)
.listen(((MapTapEvent e) => _mapState.widget.onTap?.call(e.value)));
_methodChannel.onMapLongPress(mapId: mapId).listen(((MapLongPressEvent e) {
_mapState._extensions.values.forEach((ext) => ext.onLongPress(e.value));
_mapState.widget.onLongPress?.call(e.value);
}));

_methodChannel.onPoiTouched(mapId: mapId).listen(((MapPoiTouchEvent e) {
_mapState._extensions.values.forEach((ext) => ext.onPoiTouched(e.value));
_mapState.widget.onPoiTouched?.call(e.value);
}));

_methodChannel.onMarkerTap(mapId: mapId).listen((MarkerTapEvent e) {
_mapState._extensions.values.forEach((ext) => ext.onMarkerTap(e.value));
_mapState.onMarkerTap(e.value);
});

_methodChannel.onMarkerDragEnd(mapId: mapId).listen((MarkerDragEndEvent e) {
_mapState._extensions.values
.forEach((ext) => ext.onMarkerDragEnd(e.value));
_mapState.onMarkerDragEnd(e.value, e.position);
});

_methodChannel.onPolylineTap(mapId: mapId).listen((PolylineTapEvent e) {
_mapState._extensions.values.forEach((ext) => ext.onPolylineTap(e.value));
_mapState.onPolylineTap(e.value);
});
}
Expand Down Expand Up @@ -150,4 +144,12 @@ class AMapController {
Future<LatLng> fromScreenCoordinate(ScreenCoordinate screenCoordinate) {
return _methodChannel.fromScreenLocation(screenCoordinate, mapId: mapId);
}

Future<String> getMapContentApprovalNumber() {
return _methodChannel.getMapContentApprovalNumber(mapId: mapId);
}

Future<String> getSatelliteImageApprovalNumber() {
return _methodChannel.getSatelliteImageApprovalNumber(mapId: mapId);
}
}
Loading

0 comments on commit 2a889eb

Please sign in to comment.