[TOC]
在你的pubspec.yaml
文件的dependencies节点下添加:
amap_base: x.x.x
amap_base_map: x.x.x # 仅地图
amap_base_navi: x.x.x # 仅导航(高德导航SDK已包含地图, 不要跟amap_base_map重复引用)
amap_base_search: x.x.x # 仅搜索
amap_base_location: x.x.x # 仅定位(暂未实现)
如果你想要指定某个版本/分支/提交, 那么:
amap_base:
git:
url: https://github.com/yohom/amap_base_Flutter.git
ref: 0.0.1/branch/commit
导入:
import 'package:amap_base/amap_base.dart';
Android端设置key:
<application>
...
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="您的Key"/>
</application>
iOS端设置key:
await AMap.init('您的key'); // 这个方法在Android端无效
iOS端的UiKitView
目前还只是preview状态, 默认是不支持的, 需要手动打开开关, 在info.plist文件中新增一行io.flutter.embedded_views_preview
为true
. 参考iOS view embedding support has landed on master
feature/map
分支依赖了高德3DMap库.feature/location
分支依赖了高德Location库.feature/navi
分支依赖了高德Navi库(Navi库包含了3DMap库, 不要重复引用Navi库和3DMap库!).feature/search
分支依赖了高德Search库.use_framework!
. 尝试了在podspec中添加s.static_framework = true
, 但是会造成找不到pod里的头文件. 如果有更好的解决方案, 请告知我.项目结构按照高德官方的4个子包(不包括2D地图)组织. 分为地图
, 定位
, 导航
, 搜索
四大块.
|-- me.yohom.amapbase
|-- `AMapBasePlugin`: Flutter插件类
|-- `FunctionRegistry`: 功能登记处, 所有功能都需要在此处注册.
|-- `IMapMethodHandler`: **处理委托对象**接口.
|-- common: 通用代码
|-- map: 地图功能模块
|-- handlers: 单个功能的**处理委托对象**
|-- calculatetool: `地图计算工具`
|-- createmap: `创建地图`
|-- draw: `在地图上绘制`
|-- interact: `与地图交互`
|-- model: 地图数据的模型
|-- `AMapFactory`: AMapView工厂, Flutter的platform view需要
|-- navi: 导航功能模块(未实现)
|-- search: 搜索功能模块
|-- handlers: 单个功能的**处理委托对象**
|-- fetchdata: `获取地图数据`
|-- routeplan: `出行路线规划`
|-- model: 搜索数据的模型
|-- location: 定位功能模块(未实现)
handlers
包下找到要实现的功能模块包, 比如说要实现显示地图, 那么先找到me.yohom.amapbase/map/handlers/createmap
包, 然后在该包下创建新的实现MapMethodHandler
接口的委托类.FunctionRegistry
类中注册功能.Additional arguments
增加--target-platform android-arm
.从地图
分支, 导航
分支, 定位
分支, 搜索
分支, 以提供更小的包ChangeLatLng
方法, 用来把目标位置移动到地图中心ZoomToSpan
方法切换地图图层
功能显示英文地图
功能手势交互
功能显示室内地图
功能绘制点标记
功能驾车路线规划
功能控件交互
功能显示地图
和定位蓝点
功能example/README.md
Demonstrates how to use the amap_base plugin.
For help getting started with Flutter, view our online documentation.
Add this to your package's pubspec.yaml file:
dependencies:
amap_base_map: ^0.2.0
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter packages get
Alternatively, your editor might support pub get
or flutter packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:amap_base_map/amap_base.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.2.11+3 | Jan 5, 2019 |
|
|
0.2.11+2 | Jan 5, 2019 |
|
|
0.2.11 | Jan 5, 2019 |
|
|
0.2.10+1 | Jan 4, 2019 |
|
|
0.2.10 | Jan 4, 2019 |
|
|
0.2.4 | Dec 18, 2018 |
|
|
0.2.0+1 | Dec 14, 2018 |
|
|
0.2.0 | Dec 14, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
50
|
Health:
Code health derived from static analysis.
[more]
|
0
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
80
|
Overall:
Weighted score of the above.
[more]
|
41
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms:
Low code quality prevents platform classification.
Fix lib/src/search/amap_search.dart
. (-99.99 points)
Analysis of lib/src/search/amap_search.dart
failed with 31 errors, 7 hints, including:
line 3 col 8: Target of URI doesn't exist: 'package:amap_base/amap_base.dart'.
line 4 col 8: Target of URI doesn't exist: 'package:amap_base/src/common/log.dart'.
line 5 col 8: Target of URI doesn't exist: 'package:amap_base/src/map/model/poi_result.dart'.
line 6 col 8: Target of URI doesn't exist: 'package:amap_base/src/search/model/drive_route_result.dart'.
line 26 col 10: The name 'PoiResult' isn't a type so it can't be used as a type argument.
Fix lib/src/map/amap_controller.dart
. (-99.98 points)
Analysis of lib/src/map/amap_controller.dart
failed with 30 errors, including:
line 4 col 8: Target of URI doesn't exist: 'package:amap_base/amap_base.dart'.
line 5 col 8: Target of URI doesn't exist: 'package:amap_base/src/common/log.dart'.
line 6 col 8: Target of URI doesn't exist: 'package:amap_base/src/map/model/marker_options.dart'.
line 7 col 8: Target of URI doesn't exist: 'package:amap_base/src/map/model/my_location_style.dart'.
line 8 col 8: Target of URI doesn't exist: 'package:amap_base/src/map/model/polyline_options.dart'.
Fix lib/src/map/model/poi_result.dart
. (-98.66 points)
Analysis of lib/src/map/model/poi_result.dart
failed with 15 errors, including:
line 1 col 8: Target of URI doesn't exist: 'package:amap_base/amap_base.dart'.
line 2 col 8: Target of URI doesn't exist: 'package:amap_base/src/map/model/search_bound.dart'.
line 9 col 3: Undefined class 'SearchBound'.
line 35 col 15: Undefined name 'SearchBound'.
line 162 col 3: Undefined class 'LatLng'.
Fix additional 17 files with analysis or formatting issues. (-1031.13 points)
Additional issues in the following files:
lib/src/search/model/drive_route_result.dart
(13 errors, 3 hints)lib/src/map/model/search_bound.dart
(10 errors)lib/src/map/amap_view.dart
(8 errors)lib/src/map/model/marker_options.dart
(6 errors)lib/src/map/model/route_overlay.dart
(6 errors)lib/src/common/misc.dart
(5 errors)lib/src/map/model/route_plan_param.dart
(5 errors)lib/src/map/model/ui_settings.dart
(5 errors)lib/src/map/model/poi_search_query.dart
(4 errors)lib/src/map/model/route_poi_search_query.dart
(4 errors)lib/src/map/model/amap_options.dart
(3 errors)lib/src/map/model/camera_position.dart
(3 errors)lib/src/map/model/route_poi_result.dart
(3 errors)lib/src/map/model/polyline_options.dart
(2 errors)lib/amap_base.dart
(2 hints)lib/src/map/calculate_tool.dart
(1 hint)lib/src/map/offline_manager.dart
(1 hint)Fix platform conflicts. (-20 points)
Low code quality prevents platform classification.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev.68.0 <3.0.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | ||
meta | 1.1.6 | 1.1.7 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 |