amap_map_fluttify 0.9.1+edd4090 copy "amap_map_fluttify: ^0.9.1+edd4090" to clipboard
amap_map_fluttify: ^0.9.1+edd4090 copied to clipboard

outdated

An `Amap` Map Component, Powered By `Fluttify` Engine.

Logo

高德 地图组件 #

pub package Gitter

Dart接口基于Fluttify引擎生成. dartdoc接口文档. CHANGELOG. 常见问题对应手册.

!!git clone失败看这里!!

由于高德地图的iOS端的二进制文件MAMapKit128.1MB, 超出了GitHub上传文件限制的大小(100MB), 而GitHub免费版的git-lfs限额流量(1G)已经用完, 所以git clone的时候会失败, 就算直接下载repo, MAMapKit也已经转换成了git-lfs的一个指针文件, 无法使用.

这里提供一个变通方法, 随便在一个flutter工程内依赖amap_map_fluttify, 然后flutter packages get下载flutter插件后, 去flutter的pub缓存文件夹$flutter_root/.pub-cache/hosted/pub.dartlang.org/($flutter_root是你的flutter安装文件夹)下找到amap_map_fluttify的包, 这是一个完整的插件工程, 里面含有example工程, 可以正常运行.

如果想要查看样例工程的话, 就运行这个example工程.

安装:

dependencies:
  flutter:
    sdk: flutter
  amap_map_fluttify: ^x.x.x

导入:

import 'package:amap_map_fluttify/amap_map_fluttify.dart';

使用:

/// !!使用真机调试!!
/// !注意: 只要是返回Future的方法, 一律使用`await`修饰, 确保当前方法执行完成后再执行下一行, 在不能使用`await`修饰的环境下, 在`then`方法中执行下一步.
/// 
/// 初始化:
///   1. iOS在init方法中设置
///   2. Android需要在AndroidManifest.xml里去设置, 详见 https://lbs.amap.com/api/android-sdk/gettingstarted
///     <application>
///       <meta-data
///         android:name="com.amap.api.v2.apikey"
///         android:value="您的Key"/>
///     </application>
await AmapCore.init('7a04506d15fdb7585707f7091d715ef4');
/// 如果你觉得引擎的日志太多, 可以关闭Fluttify引擎的日志
await enableFluttifyLog(false); // 关闭log

class AmapWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AmapView(
      // 地图类型
      mapType: MapType.Standard,
      // 是否显示缩放控件
      showZoomControl: true,
      // 是否显示指南针控件
      showCompass: true,
      // 是否显示比例尺控件
      showScaleControl: true,
      // 是否使能缩放手势
      zoomGesturesEnabled: true,
      // 是否使能滚动手势
      scrollGesturesEnabled: true,
      // 是否使能旋转手势
      rotateGestureEnabled: true,
      // 是否使能倾斜手势
      tiltGestureEnabled: true,
      // 缩放级别
      zoomLevel: 10, 
      // 中心点坐标
      centerCoordinate: LatLng(39, 116),
      // 标记
      markers: <MarkerOption>[], 
      // 标识点击回调
      onMarkerClick: (Marker marker) {},
      // 地图点击回调
      onMapClick: (LatLng coord) {},
      // 地图拖动回调
      onMapDrag: (MapDrag drag) {},
      // 地图创建完成回调
      onMapCreated: (controller) async {
        // requestPermission是权限请求方法, 需要你自己实现 
        // 如果不知道怎么处理, 可以参考example工程的实现, example过程依赖了`permission_handler`插件.
        if (await requestPermission()) {
          await controller.showMyLocation(true);
        }
      },
    );
  }
}

iOS Info.plist配置:

/// 使用PlatformView的声明
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
/// 定位权限声明
<key>NSLocationWhenInUseUsageDescription</key>
<string>需要定位权限</string>
/// 高德地图app白名单 打开高德地图时使用
<key>LSApplicationQueriesSchemes</key>
<array>
	<string>iosamap</string>
</array>

版本规划 #

版本的语义化 #

- +版本号迭代表示引擎更新,完善引擎能力以及修复引擎bug;
- 小版本号迭代表示无破坏性更新, 包括功能增加和bug修复;
- 次版本号迭代表示有破坏性更新, 包括但不限于接口改动, 类名改动等;
- 主版本号迭代表示底层高德SDK更换;

功能开发/bug修复(优先级从高到低) #

1. 提供详细android文档和ios文档;
2. 按照issue模板提供对应信息;
3. 用户需求度;

FAQ #

  • 这个项目跟amap_base有什么联系和区别?
    • 联系: 除了是同一个作者开发的之外没有联系;
    • 区别: amap_base使用的是常规的开发方式, 还是以MethodChannel为中心在dart和原生以及各个原生平台之间斡旋. 而fluttify系列插件是在fluttify引擎生成的dart接口之上去开发插件, 屏蔽了原生代码, 开发插件时不再需要在不同的原生代码之间斡旋, 只需要专注于整合不同平台的api即可.

请作者喝杯奶茶 #

qq群 #

LICENSE #

Copyright 2019 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.