release: 1.0.12

This commit is contained in:
Kuloud
2024-08-26 09:55:49 +08:00
parent 43ecfb8ca1
commit 0a6e9c7119
36 changed files with 172 additions and 172 deletions

View File

@ -19,7 +19,7 @@ class MarkerConfigDemoPage extends StatefulWidget {
class _State extends State<MarkerConfigDemoPage> {
static final LatLng mapCenter = const LatLng(39.909187, 116.397451);
Map<String, Marker> _markers = <String, Marker>{};
final Map<String, Marker> _markers = <String, Marker>{};
BitmapDescriptor? _markerIcon;
String? selectedMarkerId;
@ -27,11 +27,11 @@ class _State extends State<MarkerConfigDemoPage> {
LatLng latLng = LatLng(mapCenter.latitude + sin(pi / 12.0) / 20.0,
mapCenter.longitude + cos(pi / 12.0) / 20.0);
try {
print('-latLng---------${latLng}');
print('-latLng---------$latLng');
ScreenCoordinate coordinate = await controller.toScreenCoordinate(latLng);
print('-coordinate---------${coordinate}');
print('-coordinate---------$coordinate');
LatLng reLatLng = await controller.fromScreenCoordinate(coordinate);
print('-reLatLng---------${reLatLng}');
print('-reLatLng---------$reLatLng');
} catch (e) {
print(e.toString());
}
@ -119,7 +119,7 @@ class _State extends State<MarkerConfigDemoPage> {
}
void _removeAll() {
if (_markers.length > 0) {
if (_markers.isNotEmpty) {
setState(() {
_markers.clear();
selectedMarkerId = null.toString();
@ -129,7 +129,7 @@ class _State extends State<MarkerConfigDemoPage> {
void _changeInfo() async {
final Marker marker = _markers[selectedMarkerId]!;
final String newTitle = marker.infoWindow.title! + '*';
final String newTitle = '${marker.infoWindow.title!}*';
if (selectedMarkerId != null) {
setState(() {
_markers[selectedMarkerId!] = marker.copyWith(
@ -233,14 +233,12 @@ class _State extends State<MarkerConfigDemoPage> {
Widget build(BuildContext context) {
///以下几种获取自定图片的方式使用其中一种即可。
//最简单的方式
if (null == _markerIcon) {
_markerIcon = BitmapDescriptor.fromIconPath('assets/location_marker.png');
}
_markerIcon ??= BitmapDescriptor.fromIconPath('assets/location_marker.png');
//通过BitmapDescriptor.fromAssetImage的方式获取图片
// _createMarkerImageFromAsset(context);
_createMarkerImageFromAsset(context);
//通过BitmapDescriptor.fromBytes的方式获取图片
// _createMarkerImageFromBytes(context);
_createMarkerImageFromBytes(context);
final AMapWidget map = AMapWidget(
onMapCreated: _onMapCreated,
@ -299,7 +297,7 @@ class _State extends State<MarkerConfigDemoPage> {
children: <Widget>[
TextButton(
child: const Text('全部移除'),
onPressed: _markers.length > 0 ? _removeAll : null,
onPressed: _markers.isNotEmpty ? _removeAll : null,
),
AMapSwitchButton(
label: Text('允许拖动'),