提交 0f8da694 authored 作者: 史晓晨's avatar 史晓晨

feat:调试驾驶线路规划

上级 a542ec9c
......@@ -20,6 +20,9 @@ import 'src/web/utils.dart';
class AmapFlutterMapWeb extends AMapFlutterPlatform {
AmapFlutterMapWeb();
late AMap _aMap;
late DivElement _element;
static void registerWith(Registrar registrar) {
AMapFlutterPlatform.instance = AmapFlutterMapWeb();
}
......@@ -29,8 +32,6 @@ class AmapFlutterMapWeb extends AMapFlutterPlatform {
Map<String, dynamic> creationParams,
Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers,
PlatformViewCreatedCallback onPlatformViewCreated) {
late DivElement _element;
/// 这里使用时间作为唯一标识
String _divId = DateTime.now().toIso8601String();
......@@ -44,6 +45,7 @@ class AmapFlutterMapWeb extends AMapFlutterPlatform {
return _element;
});
SchedulerBinding.instance.addPostFrameCallback((_) {
/// 创建地图
var promise = load(LoaderOptions(
......@@ -57,7 +59,7 @@ class AmapFlutterMapWeb extends AMapFlutterPlatform {
MapOptions _mapOptions = MapOptions(
zoom: 13,
);
AMap aMap = AMap(_element, _mapOptions);
_aMap = AMap(_element, _mapOptions);
}, onError: (e) {
print('初始化错误:$e');
});
......@@ -68,4 +70,16 @@ class AmapFlutterMapWeb extends AMapFlutterPlatform {
onPlatformViewCreated: onPlatformViewCreated,
);
}
/// 导航
void navDriving() {
_aMap.plugin(["AMap.Driving"], allowInterop(() {
var driving = Driving(DrivingOptions(map: _aMap, panel: _element));
driving
.search(LngLat(116.379028, 39.865042), LngLat(116.427281, 39.903719),
allowInterop((status, result) {
print("=====11111 status $status result = ${stringify(result)}");
}));
}));
}
}
......@@ -10,6 +10,9 @@ import 'package:js/js.dart';
@JS('Map')
class AMap {
external AMap(dynamic /*String|HTMLDivElement*/ div, MapOptions opts);
/// 加载插件
external plugin(dynamic /*String|List*/ name, void Function() callback);
}
@JS()
......@@ -28,6 +31,34 @@ class MapOptions {
@JS()
class LngLat {
external num getLng();
external num getLat();
external LngLat(num lng, num lat);
}
@JS('Driving')
class Driving {
/// 导航
external Driving(DrivingOptions opts);
external search(LngLat origin, LngLat destination,
void Function(String status, dynamic result) callback);
}
@JS()
@anonymous
class DrivingOptions {
external factory DrivingOptions({
// 地图实例
AMap map,
// 地图显示的缩放级别
dynamic panel,
});
}
@JS()
@anonymous
class DrivingResult {
external String get info;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论