Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx_map_navigation
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx_map_navigation
Commits
d93bf6fe
提交
d93bf6fe
authored
12月 03, 2022
作者:
袁静春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交:优化导航插件;
上级
bf7410aa
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
117 行增加
和
46 行删除
+117
-46
Podfile.lock
example/ios/Podfile.lock
+1
-1
project.pbxproj
example/ios/Runner.xcodeproj/project.pbxproj
+3
-3
main.dart
example/lib/main.dart
+7
-4
map_config.dart
example/lib/map_config.dart
+8
-1
pubspec.lock
example/pubspec.lock
+7
-0
ClxMapNavigationView.m
ios/Classes/ClxMapNavigationView.m
+9
-1
amap_navigation_widget.dart
lib/amap_navigation_widget.dart
+33
-4
clx_map_navigation.dart
lib/core/clx_map_navigation.dart
+0
-23
clx_map_navigation_method_channel.dart
lib/core/clx_map_navigation_method_channel.dart
+24
-7
clx_map_navigation_platform_interface.dart
lib/core/clx_map_navigation_platform_interface.dart
+7
-1
map_event.dart
lib/core/map_event.dart
+16
-0
pubspec.yaml
pubspec.yaml
+1
-0
clx_map_navigation_test.dart
test/clx_map_navigation_test.dart
+1
-1
没有找到文件。
example/ios/Podfile.lock
浏览文件 @
d93bf6fe
...
...
@@ -25,7 +25,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AMapFoundation: f48153f724114b58da9b01875ab88a1f6856e3db
AMapNavi: 04727c06ec51fc4d7c57d83e2542da81b32f2f59
clx_map_navigation:
4eb146ec054cc72567c5b372d20ba4d0ed6ee365
clx_map_navigation:
b73614901161608d76ebfe6ec266773bdfe00b26
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d
...
...
example/ios/Runner.xcodeproj/project.pbxproj
浏览文件 @
d93bf6fe
...
...
@@ -372,7 +372,7 @@
"$(inherited)"
,
"@executable_path/Frameworks"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.clx.driver
Flutter
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.clx.driver
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
...
...
@@ -496,7 +496,7 @@
"$(inherited)"
,
"@executable_path/Frameworks"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.clx.driver
Flutter
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.clx.driver
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
...
...
@@ -515,7 +515,7 @@
"$(inherited)"
,
"@executable_path/Frameworks"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.clx.driver
Flutter
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.clx.driver
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
...
...
example/lib/main.dart
浏览文件 @
d93bf6fe
import
'package:amap_flutter_base/amap_flutter_base.dart'
;
import
'package:clx_map_navigation_example/map_config.dart'
;
import
'package:flutter/material.dart'
;
import
'package:clx_map_navigation/amap_navigation_widget.dart'
;
import
'package:clx_map_navigation/core/clx_map_navigation.dart'
;
void
main
(
)
{
runApp
(
const
MyApp
());
...
...
@@ -30,10 +28,15 @@ class _MyAppState extends State<MyApp> {
),
body:
const
AMapNavigationWidget
(
apiKey:
AMapConfig
.
aMapApiKeys
,
startPoint:
{
"latitude"
:
39.993135
,
"longitude"
:
116.474175
},
endPoint:
{
"latitude"
:
39.908791
,
"longitude"
:
116.321257
},
// startPoint: { "latitude": 39.993135, "longitude": 116.474175 },
// endPoint: { "latitude": 39.908791, "longitude": 116.321257 },
startPoint:
{
"latitude"
:
37.820494
,
"longitude"
:
112.586248
},
endPoint:
{
"latitude"
:
39.911328
,
"longitude"
:
116.152583
},
onMapClosed:
AMapConfig
.
onMapClosed
,
),
),
);
}
}
example/lib/map_config.dart
浏览文件 @
d93bf6fe
...
...
@@ -2,10 +2,16 @@ import 'package:amap_flutter_base/amap_flutter_base.dart';
class
AMapConfig
{
static
const
androidKey
=
"8395ac94201590a0e5cfe4c836b1d2c9"
;
static
const
iosKey
=
"3d2ef3dd5e6da65e19e34d34d9a403a1"
;
static
const
iosKey
=
"3d2ef3dd5e6da65e19e34d34d9a403a1"
;
//com.clx.driver
static
const
AMapApiKey
aMapApiKeys
=
AMapApiKey
(
iosKey:
iosKey
,
androidKey:
androidKey
,
);
static
onMapClosed
()
{
print
(
"----- onMapClosed ---- 处理完了"
);
}
}
\ No newline at end of file
example/pubspec.lock
浏览文件 @
d93bf6fe
...
...
@@ -156,6 +156,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
stream_transform:
dependency: transitive
description:
name: stream_transform
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
...
...
ios/Classes/ClxMapNavigationView.m
浏览文件 @
d93bf6fe
...
...
@@ -35,7 +35,8 @@
if
(
self
=
[
super
init
])
{
NSAssert
([
args
isKindOfClass
:[
NSDictionary
class
]],
@"传参错误"
);
//构建methedChannel
NSString
*
channelName
=
[
NSString
stringWithFormat
:
@"amap_flutter_map_navigation_%lld"
,
viewId
];
//NSString *channelName = [NSString stringWithFormat:@"amap_flutter_map_navigation_lld", viewId];
NSString
*
channelName
=
[
NSString
stringWithFormat
:
@"clx_map_navigation"
];
_channel
=
[
FlutterMethodChannel
methodChannelWithName
:
channelName
binaryMessenger
:
registrar
.
messenger
];
_viewId
=
viewId
;
...
...
@@ -240,6 +241,13 @@
[
driveView
removeFromSuperview
];
[[
AMapNaviDriveManager
sharedInstance
]
stopNavi
];
[[
AMapNaviDriveManager
sharedInstance
]
removeDataRepresentative
:
_driveView
];
NSMutableDictionary
*
arguments
=
[
NSMutableDictionary
dictionary
];
[
arguments
setValue
:
@"退出"
forKey
:
@"msg"
];
if
(
_channel
)
{
NSLog
(
@"driveViewCloseButtonClicked - 退出: %@"
,
arguments
);
[
_channel
invokeMethod
:
@"navigationClosed"
arguments
:
arguments
];
}
}
-
(
void
)
driveViewMoreButtonClicked
:
(
AMapNaviDriveView
*
)
driveView
{
...
...
lib/amap_navigation_widget.dart
浏览文件 @
d93bf6fe
import
'dart:async'
;
import
'package:clx_map_navigation/core/amap_navigation_util.dart'
;
import
'package:clx_map_navigation/core/clx_map_navigation_method_channel.dart'
;
import
'package:clx_map_navigation/core/clx_map_navigation_platform_interface.dart'
;
import
'package:clx_map_navigation/core/map_event.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:amap_flutter_base/amap_flutter_base.dart'
;
import
'package:flutter/services.dart'
;
final
MethodChannelClxMapNavigation
_methodChannel
=
ClxMapNavigationPlatform
.
instance
as
MethodChannelClxMapNavigation
;
typedef
void
MapClosedCallback
(
);
class
AMapNavigationWidget
extends
StatefulWidget
{
/// 高德开放平台的key
final
AMapApiKey
?
apiKey
;
/// 起点
final
Map
?
startPoint
;
/// 终点
final
Map
?
endPoint
;
///需要应用到地图上的手势集合
/// 需要应用到地图上的手势集合
final
Set
<
Factory
<
OneSequenceGestureRecognizer
>>
gestureRecognizers
;
/// 导航地图底部退出的回调
final
MapClosedCallback
?
onMapClosed
;
const
AMapNavigationWidget
({
Key
?
key
,
...
...
@@ -28,6 +31,7 @@ class AMapNavigationWidget extends StatefulWidget {
required
this
.
startPoint
,
required
this
.
endPoint
,
this
.
gestureRecognizers
=
const
<
Factory
<
OneSequenceGestureRecognizer
>>{},
this
.
onMapClosed
,
})
:
super
(
key:
key
);
@override
...
...
@@ -35,9 +39,33 @@ class AMapNavigationWidget extends StatefulWidget {
}
class
_MapNavigationState
extends
State
<
AMapNavigationWidget
>
{
@override
void
initState
()
{
super
.
initState
();
_setupChannelsConfig
();
_connectStreams
();
}
_setupChannelsConfig
()
{
_methodChannel
.
channel
().
setMethodCallHandler
((
call
)
=>
_handleMethodCall
(
call
));
}
_connectStreams
()
{
print
(
"---_connectStreams---"
);
if
(
widget
.
onMapClosed
!=
null
)
{
_methodChannel
.
onMapClosed
().
listen
((
MapClosedEvent
e
)
=>
widget
.
onMapClosed
!());
}
}
/// 原生与Flutter交互
Future
<
dynamic
>
_handleMethodCall
(
MethodCall
call
)
async
{
print
(
"------_handleMethodCall ----- "
);
switch
(
call
.
method
)
{
case
'navigationClosed'
:
_methodChannel
.
getMapEventStreamController
().
add
(
MapClosedEvent
(
""
));
break
;
}
}
@override
...
...
@@ -52,6 +80,7 @@ class _MapNavigationState extends State<AMapNavigationWidget> {
creationParams
,
widget
.
gestureRecognizers
,
onPlatformViewCreated
,
widget
.
onMapClosed
,
);
return
mapView
;
}
...
...
lib/core/clx_map_navigation.dart
deleted
100644 → 0
浏览文件 @
bf7410aa
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'clx_map_navigation_platform_interface.dart'
;
class
ClxMapNavigation
{
Future
<
String
?>
getPlatformVersion
()
{
return
ClxMapNavigationPlatform
.
instance
.
getPlatformVersion
();
}
Widget
buildMapNavigationView
(
Map
<
String
,
dynamic
>
creationParams
,
Set
<
Factory
<
OneSequenceGestureRecognizer
>>
gestureRecognizers
,
void
Function
(
int
id
)
onPlatformViewCreated
)
{
return
ClxMapNavigationPlatform
.
instance
.
buildMapNavigationView
(
creationParams
,
gestureRecognizers
,
onPlatformViewCreated
,
);
}
}
lib/core/clx_map_navigation_method_channel.dart
浏览文件 @
d93bf6fe
import
'dart:async'
;
import
'package:clx_map_navigation/amap_navigation_widget.dart'
;
import
'package:clx_map_navigation/core/map_event.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'clx_map_navigation_platform_interface.dart'
;
import
'package:stream_transform/stream_transform.dart'
;
const
VIEW_TYPE
=
'clx_map_navigation'
;
...
...
@@ -12,19 +16,16 @@ class MethodChannelClxMapNavigation extends ClxMapNavigationPlatform {
@visibleForTesting
final
methodChannel
=
const
MethodChannel
(
'clx_map_navigation'
);
@override
Future
<
String
?>
getPlatformVersion
()
async
{
final
version
=
await
methodChannel
.
invokeMethod
<
String
>(
'getPlatformVersion'
);
return
version
;
MethodChannel
channel
()
{
return
methodChannel
;
}
@override
Widget
buildMapNavigationView
(
Map
<
String
,
dynamic
>
creationParams
,
Set
<
Factory
<
OneSequenceGestureRecognizer
>>
gestureRecognizers
,
void
Function
(
int
id
)
onPlatformViewCreated
)
{
print
(
"------MethodChannelClxMapNavigation: method=buildMapNavigationView"
);
void
Function
(
int
id
)
onPlatformViewCreated
,
MapClosedCallback
?
onMapClosed
,)
{
if
(
defaultTargetPlatform
==
TargetPlatform
.
android
)
{
creationParams
[
'debugMode'
]
=
kDebugMode
;
return
AndroidView
(
...
...
@@ -45,4 +46,20 @@ class MethodChannelClxMapNavigation extends ClxMapNavigationPlatform {
}
return
Text
(
'当前平台:
$defaultTargetPlatform
, 不支持使用高德地图插件'
);
}
// handleMethodCall的`broadcast`
final
StreamController
<
MapEvent
>
_mapEventStreamController
=
StreamController
<
MapEvent
>.
broadcast
();
StreamController
<
MapEvent
>
getMapEventStreamController
()
{
return
_mapEventStreamController
;
}
// 根据mapid返回相应的event.
Stream
<
MapEvent
>
_events
()
=>
_mapEventStreamController
.
stream
;
// 底部退出回调
Stream
<
MapClosedEvent
>
onMapClosed
()
{
return
_events
().
whereType
<
MapClosedEvent
>();
}
}
lib/core/clx_map_navigation_platform_interface.dart
浏览文件 @
d93bf6fe
import
'package:clx_map_navigation/amap_navigation_widget.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -26,6 +27,10 @@ abstract class ClxMapNavigationPlatform extends PlatformInterface {
_instance
=
instance
;
}
Future
<
void
>
init
()
{
throw
UnimplementedError
(
'init() has not been implemented.'
);
}
// 获取平台版本实例
Future
<
String
?>
getPlatformVersion
()
{
throw
UnimplementedError
(
'platformVersion() has not been implemented.'
);
...
...
@@ -34,7 +39,8 @@ abstract class ClxMapNavigationPlatform extends PlatformInterface {
Widget
buildMapNavigationView
(
Map
<
String
,
dynamic
>
creationParams
,
Set
<
Factory
<
OneSequenceGestureRecognizer
>>
gestureRecognizers
,
PlatformViewCreatedCallback
onPlatformViewCreated
)
{
PlatformViewCreatedCallback
onPlatformViewCreated
,
MapClosedCallback
?
onMapClosed
,)
{
throw
UnimplementedError
(
'buildView() has not been implemented.'
);
}
...
...
lib/core/map_event.dart
0 → 100644
浏览文件 @
d93bf6fe
///地图事件处理
class
MapEvent
<
T
>
{
///返回的内容,对应的[MethodCall]中的[[arguments]]
final
T
value
;
/// 构造一个event
/// `value` 需要传输的值,可以为`null`.
MapEvent
(
this
.
value
);
}
/// 底部退出按钮关闭回调接口
class
MapClosedEvent
extends
MapEvent
<
String
>
{
MapClosedEvent
(
String
value
)
:
super
(
value
);
}
pubspec.yaml
浏览文件 @
d93bf6fe
...
...
@@ -12,6 +12,7 @@ dependencies:
sdk
:
flutter
plugin_platform_interface
:
^2.0.2
amap_flutter_base
:
^3.0.0
stream_transform
:
^2.0.0
dev_dependencies
:
flutter_test
:
...
...
test/clx_map_navigation_test.dart
浏览文件 @
d93bf6fe
import
'package:flutter_test/flutter_test.dart'
;
import
'package:clx_map_navigation/core/clx_map_navigation.dart'
;
//
import 'package:clx_map_navigation/core/clx_map_navigation.dart';
import
'package:clx_map_navigation/core/clx_map_navigation_platform_interface.dart'
;
import
'package:clx_map_navigation/core/clx_map_navigation_method_channel.dart'
;
import
'package:plugin_platform_interface/plugin_platform_interface.dart'
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论