release 1.0.4

This commit is contained in:
Kuloud
2024-01-04 18:48:31 +08:00
committed by kuloud
parent b78d128a5e
commit 4b1a1326e8
18 changed files with 606 additions and 103 deletions

View File

@ -4,9 +4,6 @@ PODS:
- amap_map (1.0.3):
- AMap3DMap
- Flutter
- amap_map_extensions (0.0.1):
- AMap3DMap
- Flutter
- AMapFoundation (1.8.2)
- Flutter (1.0.0)
- permission_handler_apple (9.1.1):
@ -14,7 +11,6 @@ PODS:
DEPENDENCIES:
- amap_map (from `.symlinks/plugins/amap_map/ios`)
- amap_map_extensions (from `.symlinks/plugins/amap_map_extensions/ios`)
- Flutter (from `Flutter`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
@ -26,8 +22,6 @@ SPEC REPOS:
EXTERNAL SOURCES:
amap_map:
:path: ".symlinks/plugins/amap_map/ios"
amap_map_extensions:
:path: ".symlinks/plugins/amap_map_extensions/ios"
Flutter:
:path: Flutter
permission_handler_apple:
@ -36,7 +30,6 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AMap3DMap: dce25dd3e51e6b92109caa7d0c97fc6055830fb3
amap_map: 8773e5cacc760edf208b1e6e61000241d26385fa
amap_map_extensions: 6d2affabf1ef14c7af8aa9eeb815b8b8453d92b0
AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6

View File

@ -6,6 +6,7 @@ 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';
import 'package:flutter/material.dart';
@ -71,6 +72,14 @@ List<Demo> overlayDemos() {
slug: 'marker-config',
configurations: [
DemoConfiguration(buildRoute: (context) => MarkerConfigDemoPage())
]),
Demo(
title: '自定义InfoWindow',
category: DemoCategory.overlay,
subtitle: '自定义与Marker绑定的InfoWindow样式',
slug: 'custom-info-window',
configurations: [
DemoConfiguration(buildRoute: (context) => CustomInfoWindowDemoPage())
])
];
}

View File

@ -8,36 +8,6 @@ import 'package:amap_map_example/theme.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
// final List<BasePage> _mapDemoPages = <BasePage>[
// AllMapConfigDemoPage('总体演示', '演示AMapWidget的所有配置项'),
// MinMaxZoomDemoPage('指定显示级别范围', '演示指定最小最大级别功能'),
// ChangeMapTypePage('切换地图图层', '演示内置的地图图层'),
// CustomMapStylePage('自定义地图', '根据自定义的地图样式文件显示地图'),
// MultiMapDemoPage('地图多实例', '同时显示多个地图'),
// ];
// final List<BasePage> _interactiveDemoPages = <BasePage>[
// MapUIDemoPage('UI控制', 'ui开关演示'),
// GesturesDemoPage('手势交互', '手势交互'),
// PoiClickDemoPage('点击poi功能', '演示点击poi之后的回调和信息透出'),
// MoveCameraDemoPage('改变地图视角', '演示改变地图的中心点、可视区域、缩放级别等功能'),
// SnapshotPage('地图截屏', '地图截屏示例'),
// ];
// final List<BasePage> _markerPages = <BasePage>[
// MarkerAddWithMapPage("随地图添加", "演示初始化地图时直接添加marker"),
// MarkerAddAfterMapPage("单独添加", "演示地图初始化之后单独添加marker功能"),
// MarkerCustomIconPage('自定义图标', '演示marker使用自定义图标功能'),
// ];
// final List<BasePage> _overlayPages = <BasePage>[
// PolylineDemoPage('Polyline操作', '演示Polyline的相关属性的操作'),
// PolylineGeodesicDemoPage('Polyline大地曲线', '演示大地曲线的添加'),
// PolylineTextureDemoPage('Polyline纹理线', '演示纹理线的添加'),
// PolygonDemoPage('Polygon操作', '演示Polygon的相关属性的操作'),
// ];
final List<Permission> needPermissionList = [
Permission.location,
Permission.storage,
@ -82,7 +52,7 @@ class _AMapDemoState extends State<AMapDemo>
@override
Widget build(BuildContext context) {
AMapInitializer.init(context, ConstConfig.amapApiKeys);
AMapInitializer.init(context, apiKey: ConstConfig.amapApiKeys);
AMapInitializer.updatePrivacyAgree(ConstConfig.amapPrivacyStatement);
return Scaffold(
appBar: AppBar(title: const Text('高德地图示例')),

View File

@ -10,7 +10,7 @@
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
import 'package:amap_map_extensions/amap_map_extensions.dart';
// import 'package:amap_map_extensions/amap_map_extensions.dart';
import 'package:flutter/material.dart';
import 'dart:typed_data';
@ -24,7 +24,7 @@ class MapWithExtensionPage extends StatefulWidget {
class _MapWithExtensionPageState extends State<MapWithExtensionPage> {
List<Widget> _approvalNumberWidget = <Widget>[];
final _extension = AmapMapExtensions();
// final _extension = AmapMapExtensions();
@override
Widget build(BuildContext context) {

View File

@ -0,0 +1,294 @@
import 'dart:async';
import 'package:amap_map_example/widgets/amap_switch_button.dart';
import 'package:flutter/material.dart';
import 'package:amap_map/amap_map.dart';
import 'package:x_amap_base/x_amap_base.dart';
import 'dart:math';
/// 自定义[InfoWindow]用例
class CustomInfoWindowDemoPage extends StatefulWidget {
const CustomInfoWindowDemoPage();
@override
State<StatefulWidget> createState() => _State();
}
class _State extends State<CustomInfoWindowDemoPage> {
static final LatLng mapCenter = const LatLng(39.909187, 116.397451);
Map<String, Marker> _markers = <String, Marker>{};
BitmapDescriptor? _markerIcon;
String? selectedMarkerId;
bool showInfoWindow = false;
final _infoWindowExtension = InfoWindowExtension(
infoWindow: Container(
color: Colors.lightBlue.shade400,
child: Text('info'),
),
option: InfoWindowOption(latLng: mapCenter));
Future<void> _onMapCreated(AMapController controller) async {}
void _add() {
final int markerCount = _markers.length;
LatLng markPostion = LatLng(
mapCenter.latitude + sin(markerCount * pi / 12.0) / 20.0,
mapCenter.longitude + cos(markerCount * pi / 12.0) / 20.0);
final Marker marker = Marker(
position: markPostion,
icon: _markerIcon!,
infoWindow: InfoWindow(title: '$markerCount 个Marker'),
onTap: (markerId) => _onMarkerTapped(markerId),
onDragEnd: (markerId, endPosition) =>
_onMarkerDragEnd(markerId, endPosition),
);
setState(() {
_markers[marker.id] = marker;
});
}
void _onMarkerTapped(String markerId) {
final Marker? tappedMarker = _markers[markerId];
final String? title = tappedMarker!.infoWindow.title;
print('$title 被点击了,markerId: $markerId');
setState(() {
selectedMarkerId = markerId;
});
}
void _onMarkerDragEnd(String markerId, LatLng position) {
final Marker? tappedMarker = _markers[markerId];
final String? title = tappedMarker!.infoWindow.title;
print('$title markerId: $markerId 被拖拽到了: $position');
}
void _remove() {
final Marker? selectedMarker = _markers[selectedMarkerId];
//有选中的Marker
if (selectedMarker != null) {
setState(() {
_markers.remove(selectedMarkerId);
});
} else {
print('无选中的Marker无法删除');
}
}
void _removeAll() {
if (_markers.length > 0) {
setState(() {
_markers.clear();
selectedMarkerId = null.toString();
});
}
}
void _changeInfo() async {
final Marker marker = _markers[selectedMarkerId]!;
final String newTitle = marker.infoWindow.title! + '*';
if (selectedMarkerId != null) {
setState(() {
_markers[selectedMarkerId!] = marker.copyWith(
infoWindowParam: marker.infoWindow.copyWith(
titleParam: newTitle,
),
);
});
}
}
void _changeAnchor() {
final Marker marker = _markers[selectedMarkerId]!;
final Offset currentAnchor = marker.anchor;
double dx = 0;
double dy = 0;
if (currentAnchor.dx < 1) {
dx = currentAnchor.dx + 0.1;
} else {
dx = 0;
}
if (currentAnchor.dy < 1) {
dy = currentAnchor.dy + 0.1;
} else {
dy = 0;
}
final Offset newAnchor = Offset(dx, dy);
setState(() {
_markers[selectedMarkerId!] = marker.copyWith(
anchorParam: newAnchor,
);
});
}
void _changePosition() {
final Marker marker = _markers[selectedMarkerId]!;
final LatLng current = marker.position;
final Offset offset = Offset(
mapCenter.latitude - current.latitude,
mapCenter.longitude - current.longitude,
);
setState(() {
_markers[selectedMarkerId!] = marker.copyWith(
positionParam: LatLng(
mapCenter.latitude + offset.dy,
mapCenter.longitude + offset.dx,
),
);
});
}
Future<void> _changeAlpha() async {
final Marker marker = _markers[selectedMarkerId]!;
final double current = marker.alpha;
setState(() {
_markers[selectedMarkerId!] = marker.copyWith(
alphaParam: current < 0.1 ? 1.0 : current * 0.75,
);
});
}
Future<void> _changeRotation() async {
final Marker marker = _markers[selectedMarkerId]!;
final double current = marker.rotation;
setState(() {
_markers[selectedMarkerId!] = marker.copyWith(
rotationParam: current == 330.0 ? 0.0 : current + 30.0,
);
});
}
Future<void> _toggleVisible(value) async {
final Marker marker = _markers[selectedMarkerId]!;
setState(() {
showInfoWindow = value;
_markers[selectedMarkerId!] = marker.copyWith(
// visibleParam: value,
);
});
}
Future<void> _toggleDraggable(value) async {
final Marker marker = _markers[selectedMarkerId]!;
setState(() {
_markers[selectedMarkerId!] = marker.copyWith(
draggableParam: value,
);
});
}
@override
Widget build(BuildContext context) {
///以下几种获取自定图片的方式使用其中一种即可。
//最简单的方式
if (null == _markerIcon) {
_markerIcon = BitmapDescriptor.fromIconPath('assets/location_marker.png');
}
_infoWindowExtension.option?.show =
_markers[selectedMarkerId] != null && showInfoWindow;
_infoWindowExtension.option?.latLng = _markers[selectedMarkerId]?.position;
final AMapWidget map = AMapWidget(
onMapCreated: _onMapCreated,
markers: Set<Marker>.of(_markers.values),
extensions: [_infoWindowExtension],
);
return Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
height: MediaQuery.of(context).size.height * 0.6,
width: MediaQuery.of(context).size.width,
child: map,
),
Expanded(
child: SingleChildScrollView(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
children: <Widget>[
Column(
children: <Widget>[
TextButton(
child: const Text('添加'),
onPressed: _add,
),
TextButton(
child: const Text('移除'),
onPressed:
(selectedMarkerId == null) ? null : _remove,
),
TextButton(
child: const Text('更新InfoWidow'),
onPressed:
(selectedMarkerId == null) ? null : _changeInfo,
),
TextButton(
child: const Text('修改锚点'),
onPressed: (selectedMarkerId == null)
? null
: _changeAnchor,
),
TextButton(
child: const Text('修改透明度'),
onPressed: (selectedMarkerId == null)
? null
: _changeAlpha,
),
],
),
Column(
children: <Widget>[
TextButton(
child: const Text('全部移除'),
onPressed: _markers.length > 0 ? _removeAll : null,
),
AMapSwitchButton(
label: Text('允许拖动'),
onSwitchChanged: (selectedMarkerId == null)
? null
: _toggleDraggable,
defaultValue: false,
),
AMapSwitchButton(
label: Text('显示'),
onSwitchChanged: (selectedMarkerId == null)
? null
: _toggleVisible,
defaultValue: true,
),
TextButton(
child: const Text('修改坐标'),
onPressed: (selectedMarkerId == null)
? null
: _changePosition,
),
TextButton(
child: const Text('修改旋转角度'),
onPressed: (selectedMarkerId == null)
? null
: _changeRotation,
),
],
),
],
)
],
),
),
),
],
),
);
}
}

View File

@ -23,7 +23,8 @@ dependencies:
# the parent directory to use the current plugin's version.
path: ../
amap_map_extensions: ^0.0.1
# amap_map_extensions: ^0.0.1
# amap_map_extensions:
# path: ../../amap_map_extensions