Skip to content

工具类 ​

本篇涵盖 OpenGL 工具、Marker 对象、POI 触摸信息、Toast 提示等辅助类。


SFMGLUtility ​

#import <SFMapSDK/SFMGLUtility.h>

SFMGLUtility 是 OpenGL 工具类(单例),提供 OpenGL 绘制辅助方法及地图引擎和投影的内部引用管理。

类型别名 ​

别名说明
me_mapenginevoid *,地图引擎指针
me_projectionvoid *,地图投影指针

属性 ​

属性说明
@property(nonatomic, assign) me_mapengine mapEngine;当前地图引擎引用
@property(nonatomic, assign) me_projection projection;当前地图投影引用
@property(nonatomic, assign) CGFloat zoomLevel;当前缩放级别

方法 ​

方法说明
+ (instancetype)sharedInstance;获取单例实例
- (void)drawTexture:(GLuint)textureId inRect:(CGRect)rect alpha:(CGFloat)alpha;绘制纹理到指定矩形
- (void)drawLineWithPoints:(CGPoint *)points count:(NSUInteger)count lineWidth:(CGFloat)width color:(UIColor *)color;绘制线条
- (void)drawPolygonWithPoints:(CGPoint *)points count:(NSUInteger)count fillColor:(UIColor *)fillColor strokeColor:(UIColor *)strokeColor;绘制多边形
- (GLuint)generateTextureFromImage:(UIImage *)image;生成纹理
- (void)deleteTexture:(GLuint)textureId;删除纹理

SFMMarker ​

#import <SFMapSDK/SFMMarker.h>

SFMMarker 表示地图上的一个标记对象,用于内部标注管理。实现 MLNAnnotation 协议。

枚举:SFMMarkerAnimateType ​

常量值说明
SFMMarkerAnimateTypeNone0无动画
SFMMarkerAnimateTypeBounce1弹跳动画
SFMMarkerAnimateTypeFadeIn2淡入动画
SFMMarkerAnimateTypeDrop3掉落动画
SFMMarkerAnimateTypeScale4缩放动画

属性 ​

属性说明
@property(nonatomic, assign) CLLocationCoordinate2D location;标记地理位置
@property(nonatomic, copy, nullable) NSString *markerIdentifier;唯一标识符
@property(nonatomic, assign) CGSize overlaySize;覆盖尺寸
@property(nonatomic, assign) BOOL canBeTouch;是否可被触摸
@property(nonatomic, assign) SFMMarkerAnimateType animateType;动画类型
@property(nonatomic, strong, nullable) UIImage *icon;标注图标
@property(nonatomic, assign) CGPoint anchor;归一化锚点 [0,1],默认 (0.5, 0.5)

方法 ​

方法说明
+ (instancetype)createMarkerWithLocation:(CLLocationCoordinate2D)location identifier:(NSString *)identifier overlaySize:(CGSize)overlaySize;创建 Marker

SFMapView Marker 管理 ​

方法说明
- (void)addMarker:(SFMMarker *)marker;添加 Marker
- (void)removeMarker:(SFMMarker *)marker;移除 Marker
- (void)removeAllMarkers;移除所有 Marker

SFMTouchPoi ​

#import <SFMapSDK/SFMTouchPoi.h>

SFMTouchPoi 表示用户在地图上点击到的 POI(兴趣点)信息。通过 delegate mapView:didTapTouchPoi: 回调获取。

属性说明
@property(nonatomic, copy, nullable) NSString *poiId;POI 唯一标识符
@property(nonatomic, copy, nullable) NSString *name;POI 名称
@property(nonatomic, assign) CLLocationCoordinate2D coordinate;POI 地理坐标
@property(nonatomic, copy, nullable) NSString *type;POI 类型

SFMToastView ​

#import <SFMapSDK/SFMToastView.h>

SFMToastView 是简单的 Toast 提示视图,继承自 UILabel,用于在地图上显示简短消息。

方法说明
- (void)showWithMessage:(NSString *)message duration:(NSTimeInterval)duration;显示 Toast 消息
- (void)showWithMessage:(NSString *)message duration:(NSTimeInterval)duration inView:(UIView *)view;在指定视图上显示 Toast
- (void)hide;隐藏 Toast

SFMViewRecycler ​

#import <SFMapSDK/SFMViewRecycler.h>

SFMViewRecycler 管理标注视图的回收复用,以提高渲染性能。通过重用标识符将不再显示的标注视图缓存,供后续相同类型标注使用。

属性/方法说明
@property(nonatomic, readonly) NSMutableDictionary<NSString *, NSMutableArray<SFMAnnotationView *> *> *reuseIdentifiersToRecycledViews;重用标识符到回收视图映射
- (nullable SFMAnnotationView *)dequeueReusableAnnotationViewWithIdentifier:(NSString *)identifier;从回收池取出视图
- (void)recycle:(SFMAnnotationView *)annotationView;回收视图到回收池
- (void)removeAll;移除所有回收视图
- (void)removeAnnotationView:(SFMAnnotationView *)annotationView;移除指定回收视图

SFMOverlayFloor ​

#import <SFMapSDK/SFMOverlayFloor.h>

SFMOverlayFloor 是覆盖物渲染图层视图,作为所有覆盖物视图的容器,负责管理层级关系和整体渲染调度。

属性/方法说明
@property(nonatomic, readonly, nonnull) NSArray<SFMOverlayView *> *overlayViews;当前图层包含的所有覆盖物视图
- (void)drawOverlaysWithIsGroundOverlayFlag:(BOOL)isGroundOverlayFlag;绘制所有覆盖物
- (void)referenceDidChange;地图引用变化时刷新覆盖物
- (void)addOverlayView:(SFMOverlayView *)overlayView;添加覆盖物视图
- (void)removeOverlayView:(SFMOverlayView *)overlayView;移除覆盖物视图
- (void)removeAllOverlayViews;移除所有覆盖物视图

V3.2-202604301400