init project

This commit is contained in:
Kuloud
2023-12-22 21:23:24 +08:00
commit 1fb3d91106
461 changed files with 58770 additions and 0 deletions

View File

@ -0,0 +1,28 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@class AMapCameraPosition;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Object interfaces
@interface AMapCameraPosition : NSObject
/// 可视区域指向的方向以角度为单位从正北向逆时针方向计算从0 度到360 度。
@property (nonatomic, assign) CGFloat bearing;
/// 目标位置的屏幕中心点经纬度坐标。
@property (nonatomic, assign) CLLocationCoordinate2D target;
/// 目标可视区域的倾斜度,以角度为单位。
@property (nonatomic, assign) CGFloat tilt;
/// 目标可视区域的缩放级别
@property (nonatomic, assign) CGFloat zoom;
- (NSDictionary *)toDictionary;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,21 @@
#import "AMapCameraPosition.h"
#import "AMapConvertUtil.h"
@implementation AMapCameraPosition
- (NSDictionary *)toDictionary {
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:4];
[dict setObject:@(self.bearing) forKey:@"bearing"];
[dict setObject:@(self.tilt) forKey:@"tilt"];
[dict setObject:@(self.zoom) forKey:@"zoom"];
if (CLLocationCoordinate2DIsValid(self.target)) {
[dict setObject:[AMapConvertUtil jsonArrayFromCoordinate:self.target] forKey:@"target"];
}
return [dict copy];
}
- (NSString *)description {
return [NSString stringWithFormat:@"CameraPosition(bearing:%.6f, target:%@, tilt:%.6f, zoom:%.6f)",self.bearing,[AMapConvertUtil stringFromCoordinate:self.target],self.tilt,self.zoom];
}
@end

View File

@ -0,0 +1,22 @@
//
// AMapInfoWindow.h
// amap_map
//
// Created by lly on 2020/11/3.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface AMapInfoWindow : NSObject
@property (nonatomic, copy) NSString* title;
@property (nonatomic, copy) NSString* snippet;
@property (nonatomic, assign) CGPoint anchor;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,12 @@
//
// AMapInfoWindow.m
// amap_map
//
// Created by lly on 2020/11/3.
//
#import "AMapInfoWindow.h"
@implementation AMapInfoWindow
@end

View File

@ -0,0 +1,44 @@
//
// AMapLocation.h
// amap_map
//
// Created by lly on 2020/11/12.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
NS_ASSUME_NONNULL_BEGIN
@class MAUserLocation;
@interface AMapLocation : NSObject
///定位提供者
///
///iOS平台只会返回'iOS'
@property (nonatomic, copy) NSString *provider;
///经纬度
@property (nonatomic, assign) CLLocationCoordinate2D latLng;
///水平精确度
@property (nonatomic, assign) double accuracy;
///海拔
@property (nonatomic, assign) double altitude;
///角度
@property (nonatomic, assign) double bearing;
///速度
@property (nonatomic, assign) double speed;
///定位时间,单位:毫秒
@property (nonatomic, assign) double time;
- (void)updateWithUserLocation:(CLLocation *)location;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,32 @@
//
// AMapLocation.m
// amap_map
//
// Created by lly on 2020/11/12.
//
#import "AMapLocation.h"
@implementation AMapLocation
- (instancetype)init {
self = [super init];
if (self) {
self.provider = @"iOS";
}
return self;
}
- (void)updateWithUserLocation:(CLLocation *)location {
if (location == nil) {
return;
}
self.latLng = location.coordinate;
self.accuracy = location.horizontalAccuracy;
self.altitude = location.altitude;
self.bearing = location.course;
self.speed = location.speed;
self.time = [location.timestamp timeIntervalSince1970]*1000;
}
@end

View File

@ -0,0 +1,58 @@
//
// AMapMarker.h
// amap_map
//
// Created by lly on 2020/11/3.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MAMapKit/MAMapKit.h>
NS_ASSUME_NONNULL_BEGIN
@class AMapInfoWindow;
@interface AMapMarker : NSObject
@property (nonatomic, copy) NSString *id_;
@property (nonatomic, assign) double alpha;
@property (nonatomic, assign) CGPoint anchor;
//原始的图片BitmapDescriptor的json存储结构
@property (nonatomic, copy) NSArray *icon;
//解析后的图片
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, assign) bool clickable;
@property (nonatomic, assign) bool draggable;
@property (nonatomic, assign) bool flat;
@property (nonatomic, assign) bool infoWindowEnable;
@property (nonatomic, strong) AMapInfoWindow *infoWindow;
@property (nonatomic, assign) CLLocationCoordinate2D position;
@property (nonatomic, assign) double rotation;
@property (nonatomic, assign) bool visible;
@property (nonatomic, assign) double zIndex;
//根据以上marker信息生成的对应的iOS端的Annotation
@property (nonatomic, strong, readonly) MAPointAnnotation *annotation;
/// 更新marker的信息
/// @param changedMarker 带修改信息的marker
- (void)updateMarker:(AMapMarker *)changedMarker;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,68 @@
//
// AMapMarker.m
// amap_map
//
// Created by lly on 2020/11/3.
//
#import "AMapMarker.h"
#import "AMapInfoWindow.h"
#import "MAPointAnnotation+Flutter.h"
@interface AMapMarker ()
@property (nonatomic, strong, readwrite) MAPointAnnotation *annotation;
@end
@implementation AMapMarker
- (instancetype)init {
self = [super init];
if (self) {
_alpha = 1.0;
_clickable = YES;
_draggable = NO;
_visible = YES;
}
return self;
}
- (MAPointAnnotation *)annotation {
if (_annotation == nil) {
NSAssert(self.id_ != nil, @"markerid不能为空");
_annotation = [[MAPointAnnotation alloc] initWithMarkerId:self.id_];
[self _updateAnnotation];
}
return _annotation;
}
/// marker
/// @param changedMarker marker
- (void)updateMarker:(AMapMarker *)changedMarker {
NSAssert((changedMarker != nil && [self.id_ isEqualToString:changedMarker.id_]), @"更新marker数据异常");
self.alpha = changedMarker.alpha;
self.anchor = changedMarker.anchor;
self.clickable = changedMarker.clickable;
self.draggable = changedMarker.draggable;
self.flat = changedMarker.flat;
self.infoWindowEnable = changedMarker.infoWindowEnable;
self.infoWindow = changedMarker.infoWindow;
self.position = changedMarker.position;
self.rotation = changedMarker.rotation;
self.visible = changedMarker.visible;
self.zIndex = changedMarker.zIndex;
if (_annotation) {//Annotation
[self _updateAnnotation];
}
}
- (void)_updateAnnotation {
_annotation.title = self.infoWindow.title;
_annotation.subtitle = self.infoWindow.snippet;
_annotation.coordinate = self.position;
}
@end

View File

@ -0,0 +1,44 @@
//
// AMapPolygon.h
// amap_map
//
// Created by lly on 2020/11/12.
//
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
#import <CoreLocation/CoreLocation.h>
NS_ASSUME_NONNULL_BEGIN
@interface AMapPolygon : NSObject{
/// 覆盖物的坐标点数组key为@"points"
CLLocationCoordinate2D *_coords;//坐标的数组指针
NSUInteger _coordCount;//坐标的个数
}
@property (nonatomic, copy) NSString *id_;
/// 边框宽度
@property (nonatomic, assign) CGFloat strokeWidth;
/// 边框颜色
@property (nonatomic, strong) UIColor *strokeColor;
/// 填充颜色
@property (nonatomic, strong) UIColor *fillColor;
/// 是否可见
@property (nonatomic, assign) bool visible;
/// 连接点类型
@property (nonatomic, assign) MALineJoinType joinType;
/// 由以上数据生成的polyline对象
@property (nonatomic, strong,readonly) MAPolygon *polygon;
- (void)updatePolygon:(AMapPolygon *)polygon;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,97 @@
//
// AMapPolygon.m
// amap_map
//
// Created by lly on 2020/11/12.
//
#import "AMapPolygon.h"
#import "AMapConvertUtil.h"
#import "MAPolygon+Flutter.h"
@interface AMapPolygon ()
@property (nonatomic, strong,readwrite) MAPolygon *polygon;
@end
@implementation AMapPolygon
- (instancetype)init {
self = [super init];
if (self) {
_visible = YES;
}
return self;
}
- (void)postHookWith:(NSDictionary *)dict {
NSArray *points = dict[@"points"];
NSAssert(points.count > 0, @"polygon传入的经纬度点有误");
//
if (_coords != NULL) {
free(_coords);
_coords = NULL;
}
_coordCount = points.count;
_coords = (CLLocationCoordinate2D*)malloc(_coordCount * sizeof(CLLocationCoordinate2D));
for (NSUInteger index = 0; index < _coordCount; index ++) {
NSArray *point = points[index];
_coords[index] = [AMapConvertUtil coordinateFromArray:point];
}
}
- (void)dealloc {
if (_coords != NULL) {
free(_coords);
_coords = NULL;
}
}
- (MAPolygon *)polygon {
if (_polygon == nil) {
_polygon = [[MAPolygon alloc] initWithPolygonId:self.id_];
[_polygon setPolygonWithCoordinates:_coords count:_coordCount];
}
return _polygon;
}
//polyline
- (void)updatePolygon:(AMapPolygon *)polygon {
NSAssert((polygon != nil && [self.id_ isEqualToString:polygon.id_]), @"更新AMapPolygon数据异常");
if ([self checkCoordsEqualWithPolyline:polygon] == NO) {//polyline
if (_coords != NULL) {
free(_coords);
_coords = NULL;
}
_coordCount = polygon->_coordCount;
_coords = (CLLocationCoordinate2D*)malloc(_coordCount * sizeof(CLLocationCoordinate2D));
for (NSUInteger index = 0; index < _coordCount; index ++) {
_coords[index] = polygon->_coords[index];
}
}
self.strokeWidth = polygon.strokeWidth;
self.strokeColor = polygon.strokeColor;
self.fillColor = polygon.fillColor;
self.visible = polygon.visible;
self.joinType = polygon.joinType;
if (_polygon) {
[_polygon setPolygonWithCoordinates:_coords count:_coordCount];
}
}
- (BOOL)checkCoordsEqualWithPolyline:(AMapPolygon *)newPolygon {
if (_coordCount != newPolygon->_coordCount) {//
return NO;
}
for (NSUInteger index = 0; index < _coordCount; index++) {
if ([AMapConvertUtil isEqualWith:_coords[index] to:newPolygon->_coords[index]] == NO) {
return NO;
}
}
return YES;
}
@end

View File

@ -0,0 +1,60 @@
//
// AMapPolyline.h
// amap_map
//
// Created by lly on 2020/11/6.
//
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
#import <CoreLocation/CoreLocation.h>
NS_ASSUME_NONNULL_BEGIN
@interface AMapPolyline : NSObject {
/// 覆盖物的坐标点数组key为@"points"
CLLocationCoordinate2D *_coords;//坐标的数组指针
NSUInteger _coordCount;//坐标的个数
}
@property (nonatomic, copy) NSString *id_;
/// 线宽
@property (nonatomic, assign) CGFloat width;
/// 覆盖物颜色,默认值为(0xCCC4E0F0).
@property (nonatomic, strong) UIColor *color;
/// 是否可见
@property (nonatomic, assign) bool visible;
/// 透明度
@property (nonatomic, assign) CGFloat alpha;
/// 自定义纹理图片
@property (nonatomic, copy) NSArray *customTexture;
/// 由customTexture解析生成的图片
@property (nonatomic, strong) UIImage *strokeImage;
/// 是否为大地曲线
@property (nonatomic, assign) BOOL geodesic;
/// 虚线类型
@property (nonatomic, assign) MALineDashType dashLineType;
/// 连接点类型
@property (nonatomic, assign) MALineJoinType joinType;
/// 线头类型
@property (nonatomic, assign) MALineCapType capType;
/// 由以上数据生成的polyline对象
@property (nonatomic, strong, readonly) MAPolyline *polyline;
//更新polyline
- (void)updatePolyline:(AMapPolyline *)polyline;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,104 @@
//
// AMapPolyline.m
// amap_map
//
// Created by lly on 2020/11/6.
//
#import "AMapPolyline.h"
#import "AMapConvertUtil.h"
#import "MAPolyline+Flutter.h"
@interface AMapPolyline ()
@property (nonatomic, strong, readwrite) MAPolyline *polyline;
@end
@implementation AMapPolyline
- (instancetype)init {
self = [super init];
if (self) {
_alpha = 1.0;
_visible = YES;
}
return self;
}
- (void)postHookWith:(NSDictionary *)dict {
NSArray *points = dict[@"points"];
NSAssert(points.count > 0, @"polyline传入的经纬度点有误");
//
if (_coords != NULL) {
free(_coords);
_coords = NULL;
}
_coordCount = points.count;
_coords = (CLLocationCoordinate2D*)malloc(_coordCount * sizeof(CLLocationCoordinate2D));
for (NSUInteger index = 0; index < _coordCount; index ++) {
NSArray *point = points[index];
_coords[index] = [AMapConvertUtil coordinateFromArray:point];
}
}
- (MAPolyline *)polyline {
if (_polyline == nil) {
if (self.geodesic) {//线使
_polyline = [[MAGeodesicPolyline alloc] initWithPolylineId:self.id_];
} else {
_polyline = [[MAPolyline alloc] initWithPolylineId:self.id_];
}
[_polyline setPolylineWithCoordinates:_coords count:_coordCount];
}
return _polyline;
}
- (void)dealloc {
if (_coords != NULL) {
free(_coords);
_coords = NULL;
}
}
//polyline
- (void)updatePolyline:(AMapPolyline *)polyline {
NSAssert((polyline != nil && [self.id_ isEqualToString:polyline.id_]), @"更新Polyline数据异常");
if ([self checkCoordsEqualWithPolyline:polyline] == NO) {//polyline
if (_coords != NULL) {
free(_coords);
_coords = NULL;
}
_coordCount = polyline->_coordCount;
_coords = (CLLocationCoordinate2D*)malloc(_coordCount * sizeof(CLLocationCoordinate2D));
for (NSUInteger index = 0; index < _coordCount; index ++) {
_coords[index] = polyline->_coords[index];
}
}
self.width = polyline.width;
self.color = polyline.color;
self.visible = polyline.visible;
self.alpha = polyline.alpha;
NSAssert(self.geodesic == polyline.geodesic, @"是否为大地曲线的变量,不允许动态修改");
self.dashLineType = polyline.dashLineType;
self.joinType = polyline.joinType;
self.capType = polyline.capType;
if (_polyline) {
[_polyline setPolylineWithCoordinates:_coords count:_coordCount];
}
}
- (BOOL)checkCoordsEqualWithPolyline:(AMapPolyline *)newPolyline {
if (_coordCount != newPolyline->_coordCount) {//
return NO;
}
for (NSUInteger index = 0; index < _coordCount; index++) {
if ([AMapConvertUtil isEqualWith:_coords[index] to:newPolyline->_coords[index]] == NO) {
return NO;
}
}
return YES;
}
@end