去掉搜索 和 定位
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -20,21 +20,11 @@ public final class GeneratedPluginRegistrant {
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error registering plugin amap_core_fluttify, me.yohom.amap_core_fluttify.AmapCoreFluttifyPlugin", e);
|
||||
}
|
||||
try {
|
||||
flutterEngine.getPlugins().add(new me.yohom.amap_location_fluttify.AmapLocationFluttifyPlugin());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error registering plugin amap_location_fluttify, me.yohom.amap_location_fluttify.AmapLocationFluttifyPlugin", e);
|
||||
}
|
||||
try {
|
||||
flutterEngine.getPlugins().add(new me.yohom.amap_map_fluttify.AmapMapFluttifyPlugin());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error registering plugin amap_map_fluttify, me.yohom.amap_map_fluttify.AmapMapFluttifyPlugin", e);
|
||||
}
|
||||
try {
|
||||
flutterEngine.getPlugins().add(new me.yohom.amap_search_fluttify.AmapSearchFluttifyPlugin());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error registering plugin amap_search_fluttify, me.yohom.amap_search_fluttify.AmapSearchFluttifyPlugin", e);
|
||||
}
|
||||
try {
|
||||
flutterEngine.getPlugins().add(new me.yohom.core_location_fluttify.CoreLocationFluttifyPlugin());
|
||||
} catch (Exception e) {
|
||||
|
@ -12,24 +12,12 @@
|
||||
@import amap_core_fluttify;
|
||||
#endif
|
||||
|
||||
#if __has_include(<amap_location_fluttify/AmapLocationFluttifyPlugin.h>)
|
||||
#import <amap_location_fluttify/AmapLocationFluttifyPlugin.h>
|
||||
#else
|
||||
@import amap_location_fluttify;
|
||||
#endif
|
||||
|
||||
#if __has_include(<amap_map_fluttify/AmapMapFluttifyPlugin.h>)
|
||||
#import <amap_map_fluttify/AmapMapFluttifyPlugin.h>
|
||||
#else
|
||||
@import amap_map_fluttify;
|
||||
#endif
|
||||
|
||||
#if __has_include(<amap_search_fluttify/AmapSearchFluttifyPlugin.h>)
|
||||
#import <amap_search_fluttify/AmapSearchFluttifyPlugin.h>
|
||||
#else
|
||||
@import amap_search_fluttify;
|
||||
#endif
|
||||
|
||||
#if __has_include(<core_location_fluttify/CoreLocationFluttifyPlugin.h>)
|
||||
#import <core_location_fluttify/CoreLocationFluttifyPlugin.h>
|
||||
#else
|
||||
@ -82,9 +70,7 @@
|
||||
|
||||
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
|
||||
[AmapCoreFluttifyPlugin registerWithRegistrar:[registry registrarForPlugin:@"AmapCoreFluttifyPlugin"]];
|
||||
[AmapLocationFluttifyPlugin registerWithRegistrar:[registry registrarForPlugin:@"AmapLocationFluttifyPlugin"]];
|
||||
[AmapMapFluttifyPlugin registerWithRegistrar:[registry registrarForPlugin:@"AmapMapFluttifyPlugin"]];
|
||||
[AmapSearchFluttifyPlugin registerWithRegistrar:[registry registrarForPlugin:@"AmapSearchFluttifyPlugin"]];
|
||||
[CoreLocationFluttifyPlugin registerWithRegistrar:[registry registrarForPlugin:@"CoreLocationFluttifyPlugin"]];
|
||||
[FoundationFluttifyPlugin registerWithRegistrar:[registry registrarForPlugin:@"FoundationFluttifyPlugin"]];
|
||||
[PathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"PathProviderPlugin"]];
|
||||
|
@ -8,8 +8,8 @@ Future<void> main() async {
|
||||
runApp(MyApp());
|
||||
|
||||
await enableFluttifyLog(false);
|
||||
await AmapSearch.instance.updatePrivacyAgree(true);
|
||||
await AmapSearch.instance.updatePrivacyShow(true);
|
||||
// await AmapSearch.instance.updatePrivacyAgree(true);
|
||||
// await AmapSearch.instance.updatePrivacyShow(true);
|
||||
await AmapService.instance.init(
|
||||
iosKey: '7a04506d15fdb7585707f7091d715ef4',
|
||||
androidKey: '7c9daac55e90a439f7b4304b465297fa',
|
||||
|
@ -390,51 +390,51 @@ class _CreateMapScreenState extends State<CreateMapScreen>
|
||||
ListTile(
|
||||
title: Center(child: Text('根据朝向旋转定位图标')),
|
||||
onTap: () {
|
||||
AmapLocation.instance
|
||||
.listenLocation()
|
||||
.listen((it) =>
|
||||
_controller.setMyLocationRotateAngle(it.bearing!))
|
||||
.addTo(disposeBag);
|
||||
// AmapLocation.instance
|
||||
// .listenLocation()
|
||||
// .listen((it) =>
|
||||
// _controller.setMyLocationRotateAngle(it.bearing!))
|
||||
// .addTo(disposeBag);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Center(child: Text('行程动画')),
|
||||
onTap: () async {
|
||||
final result = await AmapSearch.instance.searchDriveRoute(
|
||||
from: LatLng(39.958245, 116.330929),
|
||||
to: LatLng(39.915599, 116.42912),
|
||||
);
|
||||
final pathList = await result.drivePathList;
|
||||
final stepList = [
|
||||
for (final path in pathList) ...await path.driveStepList
|
||||
];
|
||||
final coordinateList = [
|
||||
for (final step in stepList) ...await step.polyline
|
||||
];
|
||||
await _controller.addPlaybackTrace(
|
||||
coordinateList,
|
||||
iconProvider: _assetsIcon,
|
||||
duration: Duration(
|
||||
milliseconds: coordinateList.length * 500,
|
||||
),
|
||||
);
|
||||
for (int i = 0; i < coordinateList.length; i++) {
|
||||
final last = coordinateList[max(i - 1, 0)];
|
||||
final current = coordinateList[i];
|
||||
await _controller.setCameraPosition(
|
||||
coordinate: coordinateList[i],
|
||||
zoom: 18,
|
||||
tilt: 45,
|
||||
bearing: bearing(
|
||||
last.latitude,
|
||||
last.longitude,
|
||||
current.latitude,
|
||||
current.longitude,
|
||||
) -
|
||||
105,
|
||||
);
|
||||
await Future.delayed(Duration(milliseconds: 500));
|
||||
}
|
||||
// final result = await AmapSearch.instance.searchDriveRoute(
|
||||
// from: LatLng(39.958245, 116.330929),
|
||||
// to: LatLng(39.915599, 116.42912),
|
||||
// );
|
||||
// final pathList = await result.drivePathList;
|
||||
// final stepList = [
|
||||
// for (final path in pathList) ...await path.driveStepList
|
||||
// ];
|
||||
// final coordinateList = [
|
||||
// for (final step in stepList) ...await step.polyline
|
||||
// ];
|
||||
// await _controller.addPlaybackTrace(
|
||||
// coordinateList,
|
||||
// iconProvider: _assetsIcon,
|
||||
// duration: Duration(
|
||||
// milliseconds: coordinateList.length * 500,
|
||||
// ),
|
||||
// );
|
||||
// for (int i = 0; i < coordinateList.length; i++) {
|
||||
// final last = coordinateList[max(i - 1, 0)];
|
||||
// final current = coordinateList[i];
|
||||
// await _controller.setCameraPosition(
|
||||
// coordinate: coordinateList[i],
|
||||
// zoom: 18,
|
||||
// tilt: 45,
|
||||
// bearing: bearing(
|
||||
// last.latitude,
|
||||
// last.longitude,
|
||||
// current.latitude,
|
||||
// current.longitude,
|
||||
// ) -
|
||||
// 105,
|
||||
// );
|
||||
// await Future.delayed(Duration(milliseconds: 500));
|
||||
// }
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -483,15 +483,15 @@ class _SecondScreen extends StatelessWidget {
|
||||
Flexible(child: AmapView()),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
AmapLocation.instance.listenLocation().listen((event) {
|
||||
print(event);
|
||||
});
|
||||
// AmapLocation.instance.listenLocation().listen((event) {
|
||||
// print(event);
|
||||
// });
|
||||
},
|
||||
child: Text('开始定位'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
AmapLocation.instance.stopLocation();
|
||||
// AmapLocation.instance.stopLocation();
|
||||
},
|
||||
child: Text('停止定位'),
|
||||
),
|
||||
|
@ -123,22 +123,22 @@ class _DrawPolylineScreenState extends State<DrawPolylineScreen>
|
||||
ListTile(
|
||||
title: Center(child: Text('添加回放轨迹')),
|
||||
onTap: () async {
|
||||
final result = await AmapSearch.instance.searchDriveRoute(
|
||||
from: LatLng(39.958245, 116.330929),
|
||||
to: LatLng(39.915599, 116.42912),
|
||||
);
|
||||
final pathList = await result.drivePathList;
|
||||
final stepList = [
|
||||
for (final path in pathList) ...await path.driveStepList
|
||||
];
|
||||
final coordinateList = [
|
||||
for (final step in stepList) ...await step.polyline
|
||||
];
|
||||
_playbackTrace = await _controller.addPlaybackTrace(
|
||||
coordinateList,
|
||||
iconProvider: _assetsIcon1,
|
||||
duration: Duration(seconds: 10),
|
||||
);
|
||||
// final result = await AmapSearch.instance.searchDriveRoute(
|
||||
// from: LatLng(39.958245, 116.330929),
|
||||
// to: LatLng(39.915599, 116.42912),
|
||||
// );
|
||||
// final pathList = await result.drivePathList;
|
||||
// final stepList = [
|
||||
// for (final path in pathList) ...await path.driveStepList
|
||||
// ];
|
||||
// final coordinateList = [
|
||||
// for (final step in stepList) ...await step.polyline
|
||||
// ];
|
||||
// _playbackTrace = await _controller.addPlaybackTrace(
|
||||
// coordinateList,
|
||||
// iconProvider: _assetsIcon1,
|
||||
// duration: Duration(seconds: 10),
|
||||
// );
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:amap_location_fluttify/amap_location_fluttify.dart';
|
||||
// import 'package:amap_location_fluttify/amap_location_fluttify.dart';
|
||||
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
|
||||
import 'package:amap_search_fluttify/amap_search_fluttify.dart';
|
||||
// import 'package:amap_search_fluttify/amap_search_fluttify.dart';
|
||||
import 'package:decorated_flutter/decorated_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -49,18 +49,18 @@ class _GeoFenceScreenState extends State<GeoFenceScreen> {
|
||||
tilt: 90,
|
||||
);
|
||||
// 搜索poi
|
||||
final poiList =
|
||||
await AmapSearch.instance.searchAround(coordinate);
|
||||
await _controller.addMarkers([
|
||||
for (final poi in poiList)
|
||||
MarkerOption(
|
||||
coordinate: poi.latLng!,
|
||||
iconProvider: AssetImage('images/test_icon.png'),
|
||||
title: poi.title!,
|
||||
snippet: poi.address!,
|
||||
object: '自定义数据: ${poi.poiId}',
|
||||
)
|
||||
]);
|
||||
// final poiList =
|
||||
// await AmapSearch.instance.searchAround(coordinate);
|
||||
// await _controller.addMarkers([
|
||||
// for (final poi in poiList)
|
||||
// MarkerOption(
|
||||
// coordinate: poi.latLng!,
|
||||
// iconProvider: AssetImage('images/test_icon.png'),
|
||||
// title: poi.title!,
|
||||
// snippet: poi.address!,
|
||||
// object: '自定义数据: ${poi.poiId}',
|
||||
// )
|
||||
// ]);
|
||||
},
|
||||
),
|
||||
Positioned(
|
||||
@ -91,11 +91,11 @@ class _GeoFenceScreenState extends State<GeoFenceScreen> {
|
||||
_fencePolygon = await _controller.addPolygon(PolygonOption(
|
||||
coordinateList: _fenceCoordinateList,
|
||||
));
|
||||
AmapLocation.instance
|
||||
.addPolygonGeoFence(pointList: _fenceCoordinateList)
|
||||
.listen((event) {
|
||||
setState(() => _fenceState = '电子围栏事件: ${event.toString()}');
|
||||
});
|
||||
// AmapLocation.instance
|
||||
// .addPolygonGeoFence(pointList: _fenceCoordinateList)
|
||||
// .listen((event) {
|
||||
// setState(() => _fenceState = '电子围栏事件: ${event.toString()}');
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,19 +14,17 @@ const _indicator = 'images/indicator.png';
|
||||
double _fabHeight = 16.0;
|
||||
|
||||
typedef RequestPermission = Future<bool> Function();
|
||||
typedef PoiItemBuilder = Widget Function(Poi poi, bool selected);
|
||||
// typedef PoiItemBuilder = Widget Function(Poi poi, bool selected);
|
||||
|
||||
class LocationPicker extends StatefulWidget {
|
||||
const LocationPicker({
|
||||
required Key key,
|
||||
required this.requestPermission,
|
||||
required this.poiItemBuilder,
|
||||
this.zoomLevel = 16.0,
|
||||
this.zoomGesturesEnabled = false,
|
||||
this.showZoomControl = false,
|
||||
required this.centerIndicator,
|
||||
this.enableLoadMore = true,
|
||||
required this.onItemSelected,
|
||||
}) : assert(zoomLevel >= 3 && zoomLevel <= 19),
|
||||
super(key: key);
|
||||
|
||||
@ -34,7 +32,7 @@ class LocationPicker extends StatefulWidget {
|
||||
final RequestPermission requestPermission;
|
||||
|
||||
/// Poi列表项Builder
|
||||
final PoiItemBuilder poiItemBuilder;
|
||||
// final PoiItemBuilder poiItemBuilder;
|
||||
|
||||
/// 显示的缩放登记
|
||||
final double zoomLevel;
|
||||
@ -52,7 +50,7 @@ class LocationPicker extends StatefulWidget {
|
||||
final bool enableLoadMore;
|
||||
|
||||
/// 选中回调
|
||||
final ValueChanged<PoiInfo> onItemSelected;
|
||||
// final ValueChanged<PoiInfo> onItemSelected;
|
||||
|
||||
@override
|
||||
_LocationPickerState createState() => _LocationPickerState();
|
||||
@ -68,7 +66,7 @@ class _LocationPickerState extends State<LocationPicker>
|
||||
bool _moveByUser = true;
|
||||
|
||||
// 当前请求到的poi列表
|
||||
List<PoiInfo> _poiInfoList = [];
|
||||
// List<PoiInfo> _poiInfoList = [];
|
||||
|
||||
// 当前地图中心点
|
||||
late LatLng _currentCenterCoordinate;
|
||||
@ -172,57 +170,76 @@ class _LocationPickerState extends State<LocationPicker>
|
||||
],
|
||||
),
|
||||
panelBuilder: (scrollController) {
|
||||
return StreamBuilder<List<PoiInfo>>(
|
||||
stream: _poiStream.stream,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final data = snapshot.data;
|
||||
return EasyRefresh(
|
||||
footer: MaterialFooter(),
|
||||
onLoad: widget.enableLoadMore ? _handleLoadMore : null,
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
controller: scrollController,
|
||||
shrinkWrap: true,
|
||||
itemCount: data!.length,
|
||||
itemBuilder: (context, index) {
|
||||
final poi = data[index].poi;
|
||||
final selected = data[index].selected;
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
// 遍历数据列表, 设置当前被选中的数据项
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i].selected = i == index;
|
||||
}
|
||||
// 如果索引是0, 说明是当前位置, 更新这个数据
|
||||
_onMyLocation.add(index == 0);
|
||||
// 刷新数据
|
||||
_poiStream.add(data);
|
||||
// 设置地图中心点
|
||||
_setCenterCoordinate(poi.latLng!);
|
||||
// 回调
|
||||
widget.onItemSelected(data[index]);
|
||||
},
|
||||
child: widget.poiItemBuilder(poi, selected),
|
||||
);
|
||||
},
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'附近位置',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
// Expanded(
|
||||
// child: _buildPoiList(scrollController),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
// return StreamBuilder<List<PoiInfo>>(
|
||||
// stream: _poiStream.stream,
|
||||
// builder: (context, snapshot) {
|
||||
// if (snapshot.hasData) {
|
||||
// final data = snapshot.data;
|
||||
// return EasyRefresh(
|
||||
// footer: MaterialFooter(),
|
||||
// onLoad: widget.enableLoadMore ? _handleLoadMore : null,
|
||||
// child: ListView.builder(
|
||||
// padding: EdgeInsets.zero,
|
||||
// controller: scrollController,
|
||||
// shrinkWrap: true,
|
||||
// itemCount: data!.length,
|
||||
// itemBuilder: (context, index) {
|
||||
// final poi = data[index].poi;
|
||||
// final selected = data[index].selected;
|
||||
// return GestureDetector(
|
||||
// onTap: () {
|
||||
// // 遍历数据列表, 设置当前被选中的数据项
|
||||
// for (int i = 0; i < data.length; i++) {
|
||||
// data[i].selected = i == index;
|
||||
// }
|
||||
// // 如果索引是0, 说明是当前位置, 更新这个数据
|
||||
// _onMyLocation.add(index == 0);
|
||||
// // 刷新数据
|
||||
// _poiStream.add(data);
|
||||
// // 设置地图中心点
|
||||
// _setCenterCoordinate(poi.latLng!);
|
||||
// // 回调
|
||||
// widget.onItemSelected(data[index]);
|
||||
// },
|
||||
// // child: widget.poiItemBuilder(poi, selected),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// } else {
|
||||
// return Center(child: CircularProgressIndicator());
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _search(LatLng location) async {
|
||||
final poiList = await AmapSearch.instance.searchAround(location);
|
||||
_poiInfoList = poiList.map((poi) => PoiInfo(poi)).toList();
|
||||
// final poiList = await AmapSearch.instance.searchAround(location);
|
||||
// _poiInfoList = poiList.map((poi) => PoiInfo(poi)).toList();
|
||||
// 默认勾选第一项
|
||||
if (_poiInfoList.isNotEmpty) _poiInfoList[0].selected = true;
|
||||
_poiStream.add(_poiInfoList);
|
||||
// if (_poiInfoList.isNotEmpty) _poiInfoList[0].selected = true;
|
||||
// _poiStream.add(_poiInfoList);
|
||||
|
||||
// 重置页数
|
||||
_page = 1;
|
||||
@ -242,25 +259,24 @@ class _LocationPickerState extends State<LocationPicker>
|
||||
}
|
||||
|
||||
Future<void> _handleLoadMore() async {
|
||||
final poiList = await AmapSearch.instance.searchAround(
|
||||
_currentCenterCoordinate,
|
||||
page: ++_page,
|
||||
);
|
||||
_poiInfoList.addAll(poiList.map((poi) => PoiInfo(poi)).toList());
|
||||
_poiStream.add(_poiInfoList);
|
||||
// final poiList = await AmapSearch.instance.searchAround(
|
||||
// _currentCenterCoordinate,
|
||||
// page: ++_page,
|
||||
// );
|
||||
// _poiInfoList.addAll(poiList.map((poi) => PoiInfo(poi)).toList());
|
||||
// _poiStream.add(_poiInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
mixin _BLoCMixin on State<LocationPicker> {
|
||||
// poi流
|
||||
final _poiStream = StreamController<List<PoiInfo>>();
|
||||
// final _poiStream = StreamController<List<PoiInfo>>();
|
||||
|
||||
// 是否在我的位置
|
||||
final _onMyLocation = StreamController<bool>();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_poiStream.close();
|
||||
_onMyLocation.close();
|
||||
super.dispose();
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import 'package:amap_search_fluttify/amap_search_fluttify.dart';
|
||||
|
||||
class PoiInfo {
|
||||
PoiInfo(this.poi);
|
||||
|
||||
final Poi poi;
|
||||
bool selected = false;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PoiInfo{poi: $poi, selected: $selected}';
|
||||
}
|
||||
}
|
||||
// import 'package:amap_search_fluttify/amap_search_fluttify.dart';
|
||||
//
|
||||
// class PoiInfo {
|
||||
// PoiInfo(this.poi);
|
||||
//
|
||||
// final Poi poi;
|
||||
// bool selected = false;
|
||||
//
|
||||
// @override
|
||||
// String toString() {
|
||||
// return 'PoiInfo{poi: $poi, selected: $selected}';
|
||||
// }
|
||||
// }
|
||||
|
@ -23,15 +23,6 @@ packages:
|
||||
url: "http://gitea.cquni.com/yangjie/amap_core_fluttify.git"
|
||||
source: git
|
||||
version: "0.17.0"
|
||||
amap_location_fluttify:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: "991d6a514973652fe891dafa4710ab08f8402547"
|
||||
url: "http://gitea.cquni.com/yangjie/amap_location_fluttify.git"
|
||||
source: git
|
||||
version: "0.22.0"
|
||||
amap_map_fluttify:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@ -39,15 +30,6 @@ packages:
|
||||
relative: true
|
||||
source: path
|
||||
version: "2.0.2"
|
||||
amap_search_fluttify:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: "9d4ce03046840e82a11f7f0fa105f8893fc9fc3f"
|
||||
url: "http://gitea.cquni.com/yangjie/amap_search_fluttify.git"
|
||||
source: git
|
||||
version: "0.18.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
Reference in New Issue
Block a user