【#DEPRECATED# 请使用 https://github.com/fluttify-project 代替】 高德地图Flutter插件 基于AndroidView和UiKitView,可以嵌入Widget树中。
amap_base | |
---|---|
amap_base_map | |
amap_base_location | |
amap_base_search | |
amap_base_navi |
[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
Android项目默认集成了androidx, 如果要使用android-support库的话, 使用android-support-library分支! 使用方法:
amap_base:
git:
url: https://github.com/yohom/amap_base_flutter.git
ref: android-support-library
path: base(/map/location/search/navi)
导入:
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
map
工程依赖了高德3DMap库.location
工程依赖了高德Location库.navi
工程依赖了高德Navi库(Navi库包含了3DMap库, 不要重复引用Navi库和3DMap库!).search
工程依赖了高德Search库.use_framework!
. 尝试了在podspec中添加s.static_framework = true
, 但是会造成找不到pod里的头文件. 如果有更好的解决方案, 请告知我.项目结构按照高德官方的4个子包(不包括2D地图)组织. 分为地图
, 定位
, 导航
, 搜索
四大块.
|-- me.yohom.amapbase
|-- `AMapBasePlugin`: Flutter插件类
|-- `FunctionRegistry`: 功能登记处, 所有功能都需要在此处注册.
|-- `IMapMethodHandler`: **处理委托对象**接口.
|-- common: 通用代码
|-- map: 地图功能模块
|-- MapHandlers
|-- MapModels: 数据模型
|-- `AMapFactory`: AMapView工厂, Flutter的platform view需要
|-- navi: 导航功能模块
|-- NaviHandlers
|-- NaviModels: 数据模型
|-- search: 搜索功能模块
|-- SearchHandlers
|-- SearchModels: 数据模型
|-- location: 定位功能模块
|-- LocationHandlers
|-- LocationModels: 数据模型
Additional arguments
增加--target-platform android-arm
.从这里打开选项对话框. VS Code
配置方式.
Copyright 2018 yohom
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.