1
This commit is contained in:
104
lib/src/enums.dart
Normal file
104
lib/src/enums.dart
Normal file
@ -0,0 +1,104 @@
|
||||
/// 地图类型
|
||||
enum MapType {
|
||||
/// 标准视图
|
||||
Standard,
|
||||
|
||||
/// 卫星视图
|
||||
Satellite,
|
||||
|
||||
/// 黑夜视图
|
||||
Night,
|
||||
|
||||
/// 导航视图
|
||||
Navi,
|
||||
|
||||
/// 公交视图
|
||||
Bus,
|
||||
}
|
||||
|
||||
/// 地图语言
|
||||
enum Language {
|
||||
/// 中文
|
||||
Chinese,
|
||||
|
||||
/// 英文
|
||||
English,
|
||||
}
|
||||
|
||||
/// 坐标类型
|
||||
enum CoordType {
|
||||
GPS,
|
||||
Google,
|
||||
MapBar,
|
||||
Baidu,
|
||||
MapABC,
|
||||
SosoMap,
|
||||
Aliyun,
|
||||
}
|
||||
|
||||
/// 线段末端处样式
|
||||
enum LineCapType {
|
||||
/// 普通头
|
||||
Butt,
|
||||
|
||||
/// 扩展头
|
||||
Square,
|
||||
|
||||
/// 箭头
|
||||
Arrow,
|
||||
|
||||
/// 圆形头
|
||||
Round,
|
||||
}
|
||||
|
||||
/// 线段连接处样式
|
||||
enum LineJoinType {
|
||||
/// 斜面连接点
|
||||
Bevel,
|
||||
|
||||
/// 斜接连接点
|
||||
Miter,
|
||||
|
||||
/// 圆角连接点
|
||||
Round,
|
||||
}
|
||||
|
||||
/// 虚线样式
|
||||
enum DashType {
|
||||
/// 方块样式
|
||||
Square,
|
||||
|
||||
/// 圆点样式
|
||||
Circle,
|
||||
}
|
||||
|
||||
enum MyLocationType {
|
||||
/// 只定位
|
||||
Show,
|
||||
|
||||
/// 定位一次, 并移动到中心
|
||||
Locate,
|
||||
|
||||
/// 跟随
|
||||
Follow,
|
||||
|
||||
/// 跟随, 但不移动到地图中心
|
||||
FollowNoCenter,
|
||||
|
||||
/// 方向跟随
|
||||
Rotate,
|
||||
}
|
||||
|
||||
/// 动画重复方式
|
||||
enum RepeatMode {
|
||||
Restart,
|
||||
Reverse,
|
||||
}
|
||||
|
||||
enum RideType {
|
||||
/// 电动车
|
||||
elebike,
|
||||
|
||||
/// 自行车
|
||||
bike,
|
||||
}
|
1
lib/src/functions.dart
Normal file
1
lib/src/functions.dart
Normal file
@ -0,0 +1 @@
|
||||
|
301
lib/src/map_controller.dart
Normal file
301
lib/src/map_controller.dart
Normal file
@ -0,0 +1,301 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:core_location_fluttify/core_location_fluttify.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'enums.dart';
|
||||
import 'models.dart';
|
||||
import 'options.dart';
|
||||
|
||||
/// marker点击事件回调签名 输入[Marker]对象
|
||||
typedef OnMarkerClicked = FutureOr<void> Function(IMarker marker);
|
||||
|
||||
/// 地图点击事件回调签名
|
||||
typedef OnMapClicked = FutureOr<void> Function(LatLng latLng);
|
||||
|
||||
/// 地图移动事件回调签名
|
||||
typedef OnMapMove = FutureOr<void> Function(MapMove move);
|
||||
|
||||
/// Marker拖动回调签名
|
||||
typedef OnMarkerDrag = FutureOr<void> Function(IMarker marker);
|
||||
|
||||
/// 地图控制类
|
||||
abstract class IMapController {
|
||||
/// Dispose map controller.
|
||||
Future<void> dispose();
|
||||
|
||||
/// Add tile overlay.
|
||||
Future<IUrlTileOverlay> addUrlTileOverlay(UrlTileOption option);
|
||||
|
||||
/// Get current location.
|
||||
Future<LatLng?> getLocation();
|
||||
|
||||
/// Show my location with [option].
|
||||
Future<void> showMyLocation(MyLocationOption option);
|
||||
|
||||
/// 设置我的位置图标旋转角度
|
||||
Future<void> setMyLocationRotateAngle(double angle);
|
||||
|
||||
/// 是否显示室内地图
|
||||
Future<void> showIndoorMap(bool show);
|
||||
|
||||
/// 选择显示图层
|
||||
Future<void> setMapType(MapType mapType);
|
||||
|
||||
/// 显示路况信息
|
||||
Future<void> showTraffic(bool enable);
|
||||
|
||||
/// 显示缩放控件
|
||||
Future<void> showZoomControl(bool enable);
|
||||
|
||||
/// 显示指南针
|
||||
Future<void> showCompass(bool enable);
|
||||
|
||||
/// 显示定位按钮
|
||||
Future<void> showLocateControl(bool enable);
|
||||
|
||||
/// 显示比例尺控件
|
||||
Future<void> showScaleControl(bool enable);
|
||||
|
||||
/// 缩放手势使能
|
||||
Future<void> setZoomGesturesEnabled(bool enable);
|
||||
|
||||
/// 滑动手势使能
|
||||
Future<void> setScrollGesturesEnabled(bool enable);
|
||||
|
||||
/// 旋转手势使能
|
||||
Future<void> setRotateGesturesEnabled(bool enable);
|
||||
|
||||
/// 旋转手势使能
|
||||
Future<void> setTiltGesturesEnabled(bool enable);
|
||||
|
||||
/// 所有手势使能
|
||||
Future<void> setAllGesturesEnabled(bool enable);
|
||||
|
||||
/// 设置缩放大小
|
||||
///
|
||||
/// 地图的缩放级别一共分为 17 级,从 3 到 19. 数字越大,展示的图面信息越精细
|
||||
Future<void> setZoomLevel(double level, {bool animated = true});
|
||||
|
||||
/// 获取当前缩放大小
|
||||
Future<double?> getZoomLevel();
|
||||
|
||||
/// 设置缩放是否以中心点为锚点
|
||||
Future<void> setZoomByCenter(bool byCenter);
|
||||
|
||||
/// 放大一个等级
|
||||
Future<void> zoomIn({bool animated = true});
|
||||
|
||||
/// 放大一个等级
|
||||
Future<void> zoomOut({bool animated = true});
|
||||
|
||||
/// 设置地图中心点
|
||||
///
|
||||
/// [lat]纬度, [lng]经度, [zoomLevel]缩放等级, [bearing]地图选择角度, [tilt]倾斜角
|
||||
Future<void> setCenterCoordinate(
|
||||
LatLng coordinate, {
|
||||
double? zoomLevel,
|
||||
double? bearing,
|
||||
double? tilt,
|
||||
bool animated = true,
|
||||
});
|
||||
|
||||
/// 获取地图中心点
|
||||
Future<LatLng?> getCenterCoordinate();
|
||||
|
||||
/// 添加marker
|
||||
///
|
||||
/// 在纬度[lat], 经度[lng]的位置添加marker, 并设置标题[title]和副标题[snippet], [iconUri]
|
||||
/// 可以是图片url, asset路径或者文件路径.
|
||||
/// 其中图片参数[imageConfig]如果不知道怎么创建, 那么就直接调用flutter sdk内提供的[createLocalImageConfiguration]方法创建
|
||||
Future<IMarker> addMarker(MarkerOption option);
|
||||
|
||||
/// 批量添加marker
|
||||
///
|
||||
/// 根据[options]批量创建Marker
|
||||
Future<List<IMarker>> addMarkers(List<MarkerOption> options);
|
||||
|
||||
/// 把marker列表从地图上移除
|
||||
Future<void> clearMarkers(List<IMarker> markers);
|
||||
|
||||
/// 清除地图上所有覆盖物
|
||||
///
|
||||
/// 根据[keepMyLocation]区分是否保留我的位置的marker
|
||||
Future<void> clear({bool keepMyLocation = true});
|
||||
|
||||
/// 屏幕坐标转经纬度坐标
|
||||
Future<LatLng?> fromScreenLocation(Point point);
|
||||
|
||||
/// 经纬度坐标转屏幕坐标
|
||||
Future<Point?> toScreenLocation(LatLng coordinate);
|
||||
|
||||
/// 添加折线
|
||||
///
|
||||
/// 可配置参数详见[PolylineOption]
|
||||
Future<IPolyline> addPolyline(PolylineOption option);
|
||||
|
||||
/// 添加多边形
|
||||
///
|
||||
/// 在点[points]的位置添加线, 可以设置宽度[width]和颜色[strokeColor]
|
||||
Future<IPolygon> addPolygon(PolygonOption option);
|
||||
|
||||
/// 添加圆
|
||||
///
|
||||
/// 在点[points]的位置添加线, 可以设置宽度[width]和颜色[strokeColor]
|
||||
Future<ICircle> addCircle(CircleOption option);
|
||||
|
||||
/// 设置marker点击监听事件
|
||||
Future<void> setMarkerClickedListener(OnMarkerClicked onMarkerClicked);
|
||||
|
||||
/// 设置marker拖动监听事件
|
||||
Future<void> setMarkerDragListener({
|
||||
OnMarkerDrag? onMarkerDragStart,
|
||||
OnMarkerDrag? onMarkerDragging,
|
||||
OnMarkerDrag? onMarkerDragEnd,
|
||||
});
|
||||
|
||||
/// 设置地图点击监听事件
|
||||
Future<void> setMapClickedListener(OnMapClicked onMapClick);
|
||||
|
||||
/// 设置地图长按监听事件
|
||||
Future<void> setMapLongPressedListener(OnMapClicked onMapLongPress);
|
||||
|
||||
/// 设置地图移动监听事件
|
||||
Future<void> setMapMoveListener({
|
||||
OnMapMove? onMapMoveStart,
|
||||
OnMapMove? onMapMoving,
|
||||
OnMapMove? onMapMoveEnd,
|
||||
});
|
||||
|
||||
/// 截图
|
||||
Future<Uint8List?> screenShot();
|
||||
|
||||
/// 限制地图的显示范围
|
||||
///
|
||||
/// [southWest]西南角, [northEast]东北角
|
||||
Future<void> setMapRegionLimits(LatLng southWest, LatLng northEast);
|
||||
|
||||
/// Marker弹窗点击事件监听
|
||||
Future<void> setInfoWindowClickListener(OnMarkerClicked onInfoWindowClicked);
|
||||
|
||||
/// 添加图片覆盖物
|
||||
Future<IGroundOverlay> addGroundOverlay(GroundOverlayOption option);
|
||||
|
||||
/// 添加热力图
|
||||
Future<IHeatmapOverlay> addHeatmapTileOverlay(HeatmapTileOption option);
|
||||
|
||||
/// 将指定的经纬度列表(包括但不限于marker, polyline, polygon等)调整至同一屏幕中显示
|
||||
///
|
||||
/// [bounds]边界点形成的边界, [padding]地图内边距
|
||||
Future<void> zoomToSpan(
|
||||
List<LatLng> bounds, {
|
||||
EdgeInsets padding = const EdgeInsets.all(50),
|
||||
bool animated = true,
|
||||
});
|
||||
|
||||
/// 自定义地图
|
||||
///
|
||||
/// 三个参数对应自定义地图压缩包内的三个文件
|
||||
Future<void> setCustomMapStyle({
|
||||
String styleDataPath,
|
||||
String styleExtraPath,
|
||||
String texturePath,
|
||||
});
|
||||
|
||||
/// 添加平滑移动marker
|
||||
///
|
||||
/// 根据[options]批量创建Marker
|
||||
Future<ISmoothMoveMarker> addSmoothMoveMarker(SmoothMoveMarkerOption option);
|
||||
|
||||
/// 添加海量点
|
||||
Future<IMultiPointOverlay> addMultiPointOverlay(MultiPointOption option);
|
||||
|
||||
/// 设置地图朝向
|
||||
///
|
||||
/// [bearing] 朝向角度, 单位为度(°), 范围为[0°,360°]
|
||||
Future<void> setBearing(double bearing, {bool animated = true});
|
||||
|
||||
/// 设置地图倾斜度
|
||||
Future<void> setTilt(double tilt, {bool animated = true});
|
||||
|
||||
/// 显示/隐藏3D楼块效果
|
||||
Future<void> showBuildings(bool show);
|
||||
|
||||
/// 显示/隐藏地图上的文字标注
|
||||
Future<void> showMapText(bool show);
|
||||
|
||||
/// 一次性设置地图视角
|
||||
Future<void> setCameraPosition({
|
||||
required LatLng coordinate,
|
||||
double? zoom,
|
||||
double? tilt,
|
||||
double? bearing,
|
||||
bool animated = true,
|
||||
Duration duration = const Duration(milliseconds: 500),
|
||||
});
|
||||
|
||||
/// 设置最大缩放等级
|
||||
Future<void> setMaxZoomLevel(double zoomLevel);
|
||||
|
||||
/// 设置最小缩放等级
|
||||
Future<void> setMinZoomLevel(double zoomLevel);
|
||||
|
||||
/// 设置地图锚点
|
||||
Future<void> setMapAnchor(double anchorU, double anchorV);
|
||||
|
||||
/// 根据起点[from]和终点[to]坐标, 搜索出路径并将驾车路线规划结果[driveRouteResult]添加到地图上, 可以配置交通拥堵情况[trafficOption],
|
||||
/// 路线的宽度[lineWidth], 自定纹理[customTexture].
|
||||
Future<void> addDriveRoute({
|
||||
required LatLng from,
|
||||
required LatLng to,
|
||||
List<LatLng>? passbyPointList,
|
||||
TrafficOption? trafficOption,
|
||||
double lineWidth = 10,
|
||||
ImageProvider? customTexture,
|
||||
});
|
||||
|
||||
/// 添加地区轮廓
|
||||
///
|
||||
/// 地区名称[districtName], 轮廓宽度[width], 轮廓颜色[strokeColor], 填充颜色[fillColor]
|
||||
///
|
||||
/// 由于一个省份可能包含多个区域, 比如浙江包含很多岛屿, 如果把岛屿也画进去, 那么会非常消耗性能.
|
||||
/// 业务上而言, 我认为这些岛屿是否画进去基本上不影响使用, 所以增加了[onlyMainDistrict]参数
|
||||
/// 来控制是否只显示主要部分的边界, 如果你对地区完整度的需求非常高, 那么就把[onlyMainDistrict]
|
||||
/// 设置为false, 随之而来像浙江这种地区的边界绘制起来就会非常慢.
|
||||
/// 我的测试结果是MIX 3, release模式下需要5-6秒才能绘制完成.
|
||||
///
|
||||
/// 采样率[sampleRate]可以控制经纬度列表的密度, 如果地区边界的经纬度列表长度非常长, 造成了卡顿,
|
||||
/// 那么可以把采样率调低一点, 这样画出来的区域可能没有采样率为1时那么精确, 但是减小了经纬度列表长度,
|
||||
/// 可以提升绘制速度.
|
||||
Future<List<IPolygon>> addDistrictOutline(
|
||||
String districtName, {
|
||||
double width = 5,
|
||||
Color strokeColor = Colors.green,
|
||||
Color fillColor = Colors.transparent,
|
||||
bool onlyMainDistrict = true,
|
||||
double sampleRate = 1.0,
|
||||
});
|
||||
|
||||
/// 添加回放轨迹
|
||||
///
|
||||
/// [coordinateList] 路径经纬度列表
|
||||
/// [width] 路径宽度
|
||||
/// [strokeColor] 路径颜色
|
||||
/// [iconProvider] 移动marker的图标
|
||||
/// [duration] 移动时长
|
||||
Future<IPlaybackTrace> addPlaybackTrace(
|
||||
List<LatLng> coordinateList, {
|
||||
double width = 5,
|
||||
Color strokeColor = Colors.green,
|
||||
required ImageProvider iconProvider,
|
||||
required Duration duration,
|
||||
});
|
||||
|
||||
/// 给地图添加padding
|
||||
Future<void> setPadding(EdgeInsets padding);
|
||||
|
||||
/// 设置的地图刷新帧率
|
||||
Future<void> setFps(int fps);
|
||||
}
|
9
lib/src/map_service.dart
Normal file
9
lib/src/map_service.dart
Normal file
@ -0,0 +1,9 @@
|
||||
/// 除了地图以外的功能放在这里, 比如说sdk初始化
|
||||
abstract class IMapService {
|
||||
/// 设置ios和android的app key
|
||||
Future<void> init({
|
||||
String? iosKey,
|
||||
String? androidKey,
|
||||
String? webKey,
|
||||
});
|
||||
}
|
100
lib/src/models.dart
Normal file
100
lib/src/models.dart
Normal file
@ -0,0 +1,100 @@
|
||||
import 'package:core_location_fluttify/core_location_fluttify.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'options.dart';
|
||||
|
||||
abstract class IOverlay {
|
||||
Future<void> remove();
|
||||
}
|
||||
|
||||
/// 地图标记
|
||||
abstract class IMarker extends IOverlay {
|
||||
/// 获取标题
|
||||
Future<String> get title;
|
||||
|
||||
/// 获取副标题
|
||||
Future<String> get snippet;
|
||||
|
||||
/// 获取定位信息
|
||||
Future<LatLng> get coordinate;
|
||||
|
||||
/// 获取自定义信息
|
||||
Future<String> get object;
|
||||
|
||||
/// 设置坐标
|
||||
Future<void> setCoordinate(LatLng coordinate);
|
||||
|
||||
/// 设置可见性
|
||||
Future<void> setVisible(bool visible);
|
||||
|
||||
/// 显示弹窗
|
||||
Future<void> showInfoWindow();
|
||||
|
||||
/// 关闭弹窗
|
||||
Future<void> hideInfoWindow();
|
||||
|
||||
/// 设置图标
|
||||
Future<void> setIcon(
|
||||
ImageProvider iconProvider,
|
||||
ImageConfiguration configuration,
|
||||
);
|
||||
|
||||
/// 设置动画
|
||||
Future<void> startAnimation(MarkerAnimation animation);
|
||||
|
||||
/// 设置角度
|
||||
///
|
||||
/// 单位度(°)
|
||||
Future<void> setAngle(double angle);
|
||||
|
||||
/// 设置标题
|
||||
Future<void> setTitle(String title);
|
||||
|
||||
/// 设置副标题
|
||||
Future<void> setSnippet(String snippet);
|
||||
}
|
||||
|
||||
/// 平滑移动点
|
||||
abstract class ISmoothMoveMarker extends IOverlay {
|
||||
Future<void> stop();
|
||||
}
|
||||
|
||||
/// 折线
|
||||
abstract class IPolyline extends IOverlay {
|
||||
/// 重新设置折线点列表
|
||||
///
|
||||
/// 可用于轨迹记录
|
||||
Future<void> setCoordinateList(List<LatLng> coordinateList);
|
||||
}
|
||||
|
||||
/// 多边形
|
||||
abstract class IPolygon extends IOverlay {
|
||||
Future<bool> contains(LatLng target);
|
||||
}
|
||||
|
||||
/// 圆形
|
||||
abstract class ICircle extends IOverlay {
|
||||
/// 设置坐标
|
||||
Future<void> setCoordinate(LatLng coordinate);
|
||||
|
||||
/// 设置半径
|
||||
Future<void> setRadius(double radius);
|
||||
}
|
||||
|
||||
/// 热力图
|
||||
abstract class IHeatmapOverlay extends IOverlay {}
|
||||
|
||||
/// 瓦片图
|
||||
abstract class IUrlTileOverlay extends IOverlay {}
|
||||
|
||||
/// 图片覆盖物
|
||||
abstract class IGroundOverlay extends IOverlay {}
|
||||
|
||||
/// 海量点
|
||||
abstract class IMultiPointOverlay extends IOverlay {}
|
||||
|
||||
/// 回放轨迹
|
||||
abstract class IPlaybackTrace extends IOverlay {
|
||||
Future<void> stop();
|
||||
}
|
580
lib/src/options.dart
Normal file
580
lib/src/options.dart
Normal file
@ -0,0 +1,580 @@
|
||||
import 'package:core_location_fluttify/core_location_fluttify.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'enums.dart';
|
||||
|
||||
/// 我的位置选项
|
||||
@immutable
|
||||
class MyLocationOption {
|
||||
MyLocationOption({
|
||||
this.show = true,
|
||||
this.myLocationType = MyLocationType.Locate,
|
||||
this.interval = Duration.zero,
|
||||
this.strokeColor = Colors.transparent,
|
||||
this.strokeWidth = 0,
|
||||
this.fillColor = Colors.transparent,
|
||||
this.iconProvider,
|
||||
this.anchorU,
|
||||
this.anchorV,
|
||||
});
|
||||
|
||||
/// 是否显示
|
||||
final bool show;
|
||||
|
||||
/// 定位类型
|
||||
final MyLocationType myLocationType;
|
||||
|
||||
/// 定位间隔
|
||||
final Duration interval;
|
||||
|
||||
/// 边框颜色
|
||||
final Color strokeColor;
|
||||
|
||||
/// 边框宽度
|
||||
final double strokeWidth;
|
||||
|
||||
/// 填充颜色
|
||||
final Color fillColor;
|
||||
|
||||
/// 图标
|
||||
///
|
||||
/// 资源图片则使用[AssetImage], 网络图片则使用[NetworkImage], 文件图片则使用[FileImage]
|
||||
final ImageProvider? iconProvider;
|
||||
|
||||
/// 锚点
|
||||
final double? anchorU, anchorV;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MyLocationOption{show: $show, myLocationType: $myLocationType, interval: $interval, strokeColor: $strokeColor, strokeWidth: $strokeWidth, fillColor: $fillColor, iconProvider: $iconProvider, anchorU: $anchorU, anchorV: $anchorV}';
|
||||
}
|
||||
}
|
||||
|
||||
/// Marker创建参数
|
||||
@immutable
|
||||
class MarkerOption {
|
||||
MarkerOption({
|
||||
required this.coordinate,
|
||||
this.title = '',
|
||||
this.snippet = '',
|
||||
this.widget,
|
||||
this.draggable = false,
|
||||
this.infoWindowEnabled = true,
|
||||
this.visible = true,
|
||||
this.rotateAngle = 0,
|
||||
this.anchorU = 0.5,
|
||||
this.anchorV = 0,
|
||||
this.object,
|
||||
this.opacity,
|
||||
this.iconProvider,
|
||||
this.iconsProvider,
|
||||
this.animationFps,
|
||||
this.infoWindow,
|
||||
}) : assert(!(widget != null && iconProvider != null),
|
||||
'widget和iconProvider不能同时设置! ');
|
||||
|
||||
/// 经纬度
|
||||
final LatLng coordinate;
|
||||
|
||||
/// 标题
|
||||
final String title;
|
||||
|
||||
/// 副标题
|
||||
final String snippet;
|
||||
|
||||
/// Widget形式的Marker
|
||||
///
|
||||
/// 不能和[iconProvider]一起用.
|
||||
/// 注意控制Widget的大小, 比如Column默认是max, 会使用地图的高度, 那么此时需要设置成min.
|
||||
final Widget? widget;
|
||||
|
||||
/// 是否可拖动
|
||||
final bool draggable;
|
||||
|
||||
/// 是否允许弹窗
|
||||
final bool infoWindowEnabled;
|
||||
|
||||
/// 是否可见
|
||||
final bool visible;
|
||||
|
||||
/// 旋转角度 单位为度(°)
|
||||
final double rotateAngle;
|
||||
|
||||
/// 横轴锚点
|
||||
final double anchorU;
|
||||
|
||||
/// 纵轴锚点
|
||||
final double anchorV;
|
||||
|
||||
/// 自定义数据 理论上可以使用任何类型的数据, 但是为了减少意外情况, 这里一律转换成String来保存
|
||||
final String? object;
|
||||
|
||||
/// 透明度
|
||||
final double? opacity;
|
||||
|
||||
/// 图标
|
||||
final ImageProvider? iconProvider;
|
||||
|
||||
/// 帧动画图标
|
||||
final List<ImageProvider>? iconsProvider;
|
||||
|
||||
/// 帧动画帧率
|
||||
///
|
||||
/// 最大60, 最小3
|
||||
final int? animationFps;
|
||||
|
||||
final Widget? infoWindow;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MarkerOption{coordinate: $coordinate, title: $title, snippet: $snippet, widget: $widget, draggable: $draggable, infoWindowEnabled: $infoWindowEnabled, visible: $visible, rotateAngle: $rotateAngle, anchorU: $anchorU, anchorV: $anchorV, object: $object, iconProvider: $iconProvider}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 平滑移动Marker创建参数
|
||||
@immutable
|
||||
class SmoothMoveMarkerOption {
|
||||
SmoothMoveMarkerOption({
|
||||
required this.path,
|
||||
required this.duration,
|
||||
required this.iconProvider,
|
||||
});
|
||||
|
||||
/// 轨迹经纬度列表
|
||||
final List<LatLng> path;
|
||||
|
||||
/// 图标
|
||||
final ImageProvider iconProvider;
|
||||
|
||||
/// 动画时长
|
||||
final Duration duration;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SmoothMoveMarkerOption{path: $path, iconProvider: $iconProvider, duration: $duration}';
|
||||
}
|
||||
}
|
||||
|
||||
/// Polyline创建参数
|
||||
@immutable
|
||||
class PolylineOption {
|
||||
PolylineOption({
|
||||
required this.coordinateList,
|
||||
this.width = 5,
|
||||
this.strokeColor = Colors.green,
|
||||
this.textureProvider,
|
||||
this.lineCapType,
|
||||
this.lineJoinType,
|
||||
this.dashType,
|
||||
});
|
||||
|
||||
/// 经纬度列表
|
||||
final List<LatLng> coordinateList;
|
||||
|
||||
/// 宽度
|
||||
final double width;
|
||||
|
||||
/// 颜色
|
||||
final Color strokeColor;
|
||||
|
||||
/// 自定义纹理
|
||||
final ImageProvider? textureProvider;
|
||||
|
||||
/// 线段末端样式
|
||||
final LineCapType? lineCapType;
|
||||
|
||||
/// 线段连接处样式
|
||||
final LineJoinType? lineJoinType;
|
||||
|
||||
/// 是否虚线
|
||||
final DashType? dashType;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PolylineOption{latLngList: $coordinateList, width: $width, strokeColor: $strokeColor, textureProvider: $textureProvider, lineCapType: $lineCapType, lineJoinType: $lineJoinType, dashType: $dashType}';
|
||||
}
|
||||
}
|
||||
|
||||
/// Polygon创建参数
|
||||
@immutable
|
||||
class PolygonOption {
|
||||
PolygonOption({
|
||||
required this.coordinateList,
|
||||
this.width = 5,
|
||||
this.strokeColor = Colors.green,
|
||||
this.fillColor = Colors.transparent,
|
||||
this.zIndex,
|
||||
});
|
||||
|
||||
/// 经纬度列表
|
||||
final List<LatLng> coordinateList;
|
||||
|
||||
/// 宽度
|
||||
final double width;
|
||||
|
||||
/// 边框颜色
|
||||
final Color strokeColor;
|
||||
|
||||
/// 填充颜色
|
||||
final Color fillColor;
|
||||
|
||||
/// z index
|
||||
final double? zIndex;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PolygonOption{latLngList: $coordinateList, width: $width, strokeColor: $strokeColor, fillColor: $fillColor}';
|
||||
}
|
||||
}
|
||||
|
||||
/// Circle创建参数
|
||||
@immutable
|
||||
class CircleOption {
|
||||
/// 中心点经纬度
|
||||
final LatLng center;
|
||||
|
||||
/// 宽度
|
||||
final double radius;
|
||||
|
||||
/// 宽度
|
||||
final double width;
|
||||
|
||||
/// 边框颜色
|
||||
final Color strokeColor;
|
||||
|
||||
/// 填充颜色
|
||||
final Color fillColor;
|
||||
|
||||
CircleOption({
|
||||
required this.center,
|
||||
required this.radius,
|
||||
this.width = 5,
|
||||
this.strokeColor = Colors.green,
|
||||
this.fillColor = Colors.transparent,
|
||||
});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CircleOption{center: $center, radius: $radius, width: $width, strokeColor: $strokeColor, fillColor: $fillColor}';
|
||||
}
|
||||
}
|
||||
|
||||
/// TileOverlay创建参数
|
||||
@immutable
|
||||
class HeatmapTileOption {
|
||||
HeatmapTileOption({
|
||||
required this.coordinateList,
|
||||
this.gradient,
|
||||
});
|
||||
|
||||
/// 中心点经纬度
|
||||
final List<LatLng> coordinateList;
|
||||
|
||||
/// 热力图渐变色配置
|
||||
///
|
||||
/// [RadialGradient.stops]的值范围为(0,1), 默认值为[0.2,0.5,0.9]
|
||||
/// [RadialGradient.stops]和[RadialGradient.colors]列表的长度必须一致
|
||||
final RadialGradient? gradient;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'HeatmapTileOption{latLngList: $coordinateList}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 图片覆盖物创建参数
|
||||
@immutable
|
||||
class GroundOverlayOption {
|
||||
GroundOverlayOption({
|
||||
required this.southWest,
|
||||
required this.northEast,
|
||||
required this.imageProvider,
|
||||
});
|
||||
|
||||
final LatLng southWest;
|
||||
final LatLng northEast;
|
||||
final ImageProvider imageProvider;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GroundOverlayOption{southWest: $southWest, northEast: $northEast, imageProvider: $imageProvider}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 瓦片图创建参数
|
||||
@immutable
|
||||
class UrlTileOption {
|
||||
UrlTileOption({
|
||||
required this.width,
|
||||
required this.height,
|
||||
required this.urlTemplate,
|
||||
});
|
||||
|
||||
/// 单位瓦片图宽度
|
||||
final int width;
|
||||
|
||||
/// 单位瓦片图高度
|
||||
final int height;
|
||||
|
||||
/// 瓦片图地址模板
|
||||
///
|
||||
/// 瓦片图地址模板是一个包含"{x}","{y}","{z}","{scale}"的字符串,"{x}","{y}","{z}","{scale}"会被tile path的值所替换,
|
||||
/// 并生成用来加载tile图片数据的URL 。例如 http://server/path?x={x}&y={y}&z={z}&scale={scale}
|
||||
final String urlTemplate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UrlTileOption{width: $width, height: $height, urlTemplate: $urlTemplate}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 海量点创建参数
|
||||
@immutable
|
||||
class MultiPointOption {
|
||||
MultiPointOption({
|
||||
required this.pointList,
|
||||
this.iconProvider,
|
||||
});
|
||||
|
||||
/// 点列表
|
||||
final List<PointOption> pointList;
|
||||
|
||||
/// 图标
|
||||
final ImageProvider? iconProvider;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MultiPointOption{pointList: $pointList, iconProvider: $iconProvider}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 海量点中单个点的创建参数
|
||||
@immutable
|
||||
class PointOption {
|
||||
PointOption({
|
||||
required this.coordinate,
|
||||
this.id,
|
||||
this.title,
|
||||
this.snippet,
|
||||
this.object,
|
||||
});
|
||||
|
||||
/// 经纬度
|
||||
final LatLng coordinate;
|
||||
|
||||
/// 点的id列表, 用来区分点
|
||||
final String? id;
|
||||
|
||||
/// 标题列表
|
||||
final String? title;
|
||||
|
||||
/// 副标题列表
|
||||
final String? snippet;
|
||||
|
||||
/// 自定义数据
|
||||
final String? object;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PointOption{coordinate: $coordinate, id: $id, title: $title, snippet: $snippet, object: $object}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 地图移动
|
||||
@immutable
|
||||
class MapMove {
|
||||
MapMove({
|
||||
this.coordinate,
|
||||
this.zoom,
|
||||
this.tilt,
|
||||
this.bearing,
|
||||
this.isAbroad,
|
||||
});
|
||||
|
||||
/// 经纬度
|
||||
final LatLng? coordinate;
|
||||
|
||||
/// 缩放等级
|
||||
final double? zoom;
|
||||
|
||||
/// 倾斜度
|
||||
final double? tilt;
|
||||
|
||||
/// 朝向
|
||||
final double? bearing;
|
||||
|
||||
/// 是否是国外
|
||||
final bool? isAbroad;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MapMove{latLng: $coordinate, zoom: $zoom, tilt: $tilt, bearing: $bearing, isAbroad: $isAbroad}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 屏幕坐标
|
||||
@immutable
|
||||
class TraceLocation {
|
||||
TraceLocation({
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.speed,
|
||||
required this.bearing,
|
||||
required this.time,
|
||||
});
|
||||
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final double speed;
|
||||
final double bearing;
|
||||
final int time;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TraceLocation{latitude: $latitude, longitude: $longitude, speed: $speed, bearing: $bearing, time: $time}';
|
||||
}
|
||||
}
|
||||
|
||||
/// 交通配置
|
||||
@immutable
|
||||
class TrafficOption {
|
||||
TrafficOption({
|
||||
required this.show,
|
||||
this.goodColor = Colors.green,
|
||||
this.badColor = Colors.yellow,
|
||||
this.terribleColor = Colors.red,
|
||||
this.unknownColor = Colors.blue,
|
||||
});
|
||||
|
||||
/// 是否显示
|
||||
final bool show;
|
||||
|
||||
/// 通畅路段颜色
|
||||
final Color goodColor;
|
||||
|
||||
/// 缓行路段颜色
|
||||
final Color badColor;
|
||||
|
||||
/// 拥堵路段颜色
|
||||
final Color terribleColor;
|
||||
|
||||
/// 未知路段颜色
|
||||
final Color unknownColor;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TrafficOption{show: $show, goodColor: $goodColor, badColor: $badColor, terribleColor: $terribleColor, unknownColor: $unknownColor}';
|
||||
}
|
||||
}
|
||||
|
||||
/// marker动画基类
|
||||
@immutable
|
||||
class MarkerAnimation {
|
||||
MarkerAnimation(
|
||||
this.duration,
|
||||
this.repeatCount,
|
||||
this.repeatMode,
|
||||
this.fromValue,
|
||||
this.toValue,
|
||||
);
|
||||
|
||||
final Duration duration;
|
||||
final int repeatCount;
|
||||
final RepeatMode repeatMode;
|
||||
final double? fromValue;
|
||||
final double? toValue;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MarkerAnimation{duration: $duration, repeatCount: $repeatCount, repeatMode: $repeatMode, fromValue: $fromValue, toValue: $toValue}';
|
||||
}
|
||||
}
|
||||
|
||||
/// marker缩放动画
|
||||
@immutable
|
||||
class ScaleMarkerAnimation extends MarkerAnimation {
|
||||
ScaleMarkerAnimation({
|
||||
Duration duration = const Duration(seconds: 1),
|
||||
int repeatCount = 1,
|
||||
RepeatMode repeatMode = RepeatMode.Reverse,
|
||||
double? fromValue,
|
||||
double? toValue,
|
||||
}) : super(duration, repeatCount, repeatMode, fromValue, toValue);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ScaleMarkerAnimation{fromValue: $fromValue, toValue: $toValue}';
|
||||
}
|
||||
}
|
||||
|
||||
/// marker透明度动画
|
||||
@immutable
|
||||
class AlphaMarkerAnimation extends MarkerAnimation {
|
||||
AlphaMarkerAnimation({
|
||||
Duration duration = const Duration(seconds: 1),
|
||||
int repeatCount = 1,
|
||||
RepeatMode repeatMode = RepeatMode.Reverse,
|
||||
double? fromValue,
|
||||
double? toValue,
|
||||
}) : super(duration, repeatCount, repeatMode, fromValue, toValue);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AlphaMarkerAnimation{fromValue: $fromValue, toValue: $toValue}';
|
||||
}
|
||||
}
|
||||
|
||||
/// marker旋转动画
|
||||
@immutable
|
||||
class RotateMarkerAnimation extends MarkerAnimation {
|
||||
RotateMarkerAnimation({
|
||||
Duration duration = const Duration(seconds: 1),
|
||||
int repeatCount = 1,
|
||||
RepeatMode repeatMode = RepeatMode.Reverse,
|
||||
double? fromValue,
|
||||
double? toValue,
|
||||
}) : super(duration, repeatCount, repeatMode, fromValue, toValue);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RotateMarkerAnimation{fromValue: $fromValue, toValue: $toValue}';
|
||||
}
|
||||
}
|
||||
|
||||
/// marker移动动画
|
||||
@immutable
|
||||
class TranslateMarkerAnimation extends MarkerAnimation {
|
||||
TranslateMarkerAnimation({
|
||||
Duration duration = const Duration(seconds: 1),
|
||||
int repeatCount = 1,
|
||||
RepeatMode repeatMode = RepeatMode.Reverse,
|
||||
required this.coordinate,
|
||||
}) : super(duration, repeatCount, repeatMode, null, null);
|
||||
|
||||
final LatLng coordinate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TranslateMarkerAnimation{toValue: $coordinate}';
|
||||
}
|
||||
}
|
||||
|
||||
/// marker动画集合
|
||||
@immutable
|
||||
class MarkerAnimationSet extends MarkerAnimation {
|
||||
MarkerAnimationSet({
|
||||
this.animationSet,
|
||||
required Duration duration,
|
||||
int repeatCount = 1,
|
||||
RepeatMode repeatMode = RepeatMode.Reverse,
|
||||
}) : super(duration, repeatCount, repeatMode, null, null);
|
||||
|
||||
final List<MarkerAnimation>? animationSet;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'MarkerAnimationSet{animationSet: $animationSet}';
|
||||
}
|
||||
}
|
11
lib/uni_map_platform_interface.dart
Normal file
11
lib/uni_map_platform_interface.dart
Normal file
@ -0,0 +1,11 @@
|
||||
library uni_map_platform_interface;
|
||||
|
||||
export 'package:core_location_fluttify/core_location_fluttify.dart';
|
||||
export 'package:foundation_fluttify/foundation_fluttify.dart';
|
||||
|
||||
export 'src/enums.dart';
|
||||
export 'src/functions.dart';
|
||||
export 'src/map_controller.dart';
|
||||
export 'src/map_service.dart';
|
||||
export 'src/models.dart';
|
||||
export 'src/options.dart';
|
Reference in New Issue
Block a user