You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

291 lines
14 KiB

//
// MAOverlayRenderer.h
// MAMapKit
//
//
// Copyright (c) 2011年 Amap. All rights reserved.
//
#import "MAConfig.h"
#import <UIKit/UIKit.h>
#import "MAOverlay.h"
#import "MALineDrawType.h"
///虚线类型
typedef NS_ENUM(NSUInteger, MALineDashType) {
kMALineDashTypeNone = 0, ///<不画虚线
kMALineDashTypeSquare, ///<方块样式
kMALineDashTypeDot, ///<圆点样式
};
#define kMAOverlayRendererDefaultStrokeColor [UIColor colorWithRed:0.3 green:0.63 blue:0.89 alpha:0.8]
#define kMAOverlayRendererDefaultFillColor [UIColor colorWithRed:0.77 green:0.88 blue:0.94 alpha:0.8]
@protocol MAOverlayRenderDelegate;
///该类是地图覆盖物Renderer的基类, 提供绘制overlay的接口但并无实际的实现(render相关方法只能在重写后的glRender方法中使用)
@interface MAOverlayRenderer : NSObject {
@protected
GLuint _strokeTextureID;
BOOL _needsUpdate;
BOOL _needsLoadStrokeTexture;
}
///由地图添加时,不要手动设置。如果不是使用mapview进行添加,则需要手动设置。(since 5.1.0)
@property (nonatomic, weak) id<MAOverlayRenderDelegate> rendererDelegate;
///关联的overlay对象
@property (nonatomic, readonly, retain) id <MAOverlay> overlay;
///用于生成笔触纹理id的图片(image需满足: 长宽相等,且宽度值为2的整数次幂; 如果您需要减轻绘制产生的锯齿,您可以参考AMap.bundle中的traffic_texture_blue.png的方式,在image两边增加部分透明像素.)。(since 5.3.0)
@property (nonatomic, strong) UIImage *strokeImage;
///笔触纹理id, 修改纹理id参考, 如果strokeImage未指定、尚未加载或加载失败返回0
@property (nonatomic, readonly) GLuint strokeTextureID;
///透明度[0,1],默认为1. 使用MAOverlayRenderer类提供的渲染接口会自动应用此属性。(since 5.1.0)
@property (nonatomic, assign) CGFloat alpha;
///overlay渲染的scale。(since 5.1.0)
@property (nonatomic, readonly) CGFloat contentScale;
/**
* @brief Overlay Renderer
* @param overlay overlay对象
* @return overlay view,nil
*/
- (instancetype)initWithOverlay:(id<MAOverlay>)overlay;
/**
* @brief view矩阵16. NULL
* @return
*/
- (float *)getViewMatrix;
/**
* @brief projection矩阵16. NULL
* @return
*/
- (float *)getProjectionMatrix;
/**
* @brief gl坐标since 5.1.0
* @return
*/
- (MAMapPoint)getOffsetPoint;
/**
* @brief since 5.1.0
* @return
*/
- (CGFloat)getMapZoomLevel;
/**
* @brief MAMapPoint转换为opengles可以直接使用的坐标
* @param mapPoint MAMapPoint坐标
* @return
*/
- (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint;
/**
* @brief MAMapPoint转换为opengles可以直接使用的坐标
* @param mapPoints MAMapPoint坐标数据指针
* @param count
* @return ()
*/
- (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count;
/**
* @brief OpenGLES尺寸
* @param windowWidth
* @return OpenGLES尺寸
*/
- (CGFloat)glWidthForWindowWidth:(CGFloat)windowWidth;
/**
* @brief 使OpenGLES 线
* @param points OpenGLES坐标系点指针, - (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param pointCount
* @param strokeColor 线
* @param lineWidth OpenGLES支持线宽尺寸, - (CGFloat)glWidthForWindowWidth:(CGFloat)windowWidth
* @param looped , polyline会设置NO, polygon会设置YES
*/
- (void)renderLinesWithPoints:(CGPoint *)points
pointCount:(NSUInteger)pointCount
strokeColor:(UIColor *)strokeColor
lineWidth:(CGFloat)lineWidth
looped:(BOOL)looped __attribute__((deprecated("已废弃")));;
/**
* @brief 使OpenGLES 线
* @param points OpenGLES坐标系点指针, - (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param pointCount
* @param strokeColor 线
* @param lineWidth OpenGLES支持线宽尺寸, - (CGFloat)glWidthForWindowWidth:(CGFloat)windowWidth
* @param looped , polyline会设置NO, polygon会设置YES
* @param lineJoinType 线
* @param lineCapType 线
* @param lineDash 线
*/
- (void)renderLinesWithPoints:(CGPoint *)points
pointCount:(NSUInteger)pointCount
strokeColor:(UIColor *)strokeColor
lineWidth:(CGFloat)lineWidth
looped:(BOOL)looped
LineJoinType:(MALineJoinType)lineJoinType
LineCapType:(MALineCapType)lineCapType
lineDash:(MALineDashType)lineDash __attribute__((deprecated("已废弃")));
/**
* @brief 使OpenGLES 线
* @param points OpenGLES坐标系点指针, - (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param pointCount
* @param lineWidth 线OpenGLES支持线宽尺寸, - (CGFloat)glWidthForWindowWidth:(CGFloat)windowWidth
* @param textureID
* @param looped , polyline会设置NO, polygon会设置YES
*/
- (void)renderTexturedLinesWithPoints:(CGPoint *)points
pointCount:(NSUInteger)pointCount
lineWidth:(CGFloat)lineWidth
textureID:(GLuint)textureID
looped:(BOOL)looped __attribute__((deprecated("已废弃")));
/**
* @brief 使OpenGLES 线
* @param points OpenGLES坐标系点指针, - (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param pointCount
* @param lineWidth 线OpenGLES支持线宽尺寸, - (CGFloat)glWidthForWindowWidth:(CGFloat)windowWidth
* @param textureIDs 使- (BOOL)loadStrokeTextureImages:(NSArray *)textureImages;,strokeTextureIDs属性中获取
* @param drawStyleIndexes NSNumber,0
* @param looped , polyline会设置NO, polygon会设置YES
*/
- (void)renderTexturedLinesWithPoints:(CGPoint *)points
pointCount:(NSUInteger)pointCount
lineWidth:(CGFloat)lineWidth
textureIDs:(NSArray *)textureIDs
drawStyleIndexes:(NSArray *)drawStyleIndexes
looped:(BOOL)looped __attribute__((deprecated("已废弃")));
/**
* @brief 使OpenGLES 线
* @param points OpenGLES坐标系点指针, - (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param pointCount
* @param strokeColors
* @param drawStyleIndexes NSNumber,0
* @param isGradient
* @param lineWidth 线OpenGLES支持线宽尺寸, - (CGFloat)glWidthForWindowWidth:(CGFloat)windowWidth
* @param looped , polyline会设置NO, polygon会设置YES
* @param lineJoinType 线
* @param lineCapType 线
* @param lineDash 线
*/
- (void)renderLinesWithPoints:(CGPoint *)points
pointCount:(NSUInteger)pointCount
strokeColors:(NSArray *)strokeColors
drawStyleIndexes:(NSArray *)drawStyleIndexes
isGradient:(BOOL)isGradient
lineWidth:(CGFloat)lineWidth
looped:(BOOL)looped
LineJoinType:(MALineJoinType)lineJoinType
LineCapType:(MALineCapType)lineCapType
lineDash:(MALineDashType)lineDash __attribute__((deprecated("已废弃")));
/**
* @brief 使OpenGLES
* @param points OpenGLES坐标系点指针, - (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param pointCount
* @param fillColor
* @param usingTriangleFan YESNO
*/
- (void)renderRegionWithPoints:(CGPoint *)points
pointCount:(NSUInteger)pointCount
fillColor:(UIColor *)fillColor
usingTriangleFan:(BOOL)usingTriangleFan __attribute__((deprecated("已废弃")));
/**
* @brief 使OpenGLES (线) \n注意strokeLineWidth为0 strokeColor为nil 线
* @param points OpenGLES坐标系点指针, - (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param pointCount
* @param fillColor
* @param strokeColor 线
* @param strokeLineWidth 线OpenGLES支持线宽尺寸, - (CGFloat)glWidthForWindowWidth:(CGFloat)windowWidth
* @param strokeLineJoinType 线
* @param strokeLineDash 线
* @param usingTriangleFan YESNO
*/
- (void)renderStrokedRegionWithPoints:(CGPoint *)points pointCount:(NSUInteger)pointCount
fillColor:(UIColor *)fillColor
strokeColor:(UIColor *)strokeColor
strokeLineWidth:(CGFloat)strokeLineWidth
strokeLineJoinType:(MALineJoinType)strokeLineJoinType
strokeLineDash:(MALineDashType)strokeLineDash
usingTriangleFan:(BOOL)usingTriangleFan __attribute__((deprecated("已废弃")));
/**
* @brief 使OpenGLES (线) \n注意strokeLineWidth为0 strokeTexture为0 线
* @param points OpenGLES坐标系点指针, - (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param pointCount
* @param fillColor
* @param strokeLineWidth 线OpenGLES支持线宽尺寸, - (CGFloat)glWidthForWindowWidth:(CGFloat)windowWidth
* @param strokeTexture 线使- (void)loadStrokeTextureImage:(UIImage *)textureImage;
* @param usingTriangleFan YESNO
*/
- (void)renderTextureStrokedRegionWithPoints:(CGPoint *)points
pointCount:(NSUInteger)pointCount
fillColor:(UIColor *)fillColor
strokeTineWidth:(CGFloat)strokeLineWidth
strokeTextureID:(GLuint)strokeTexture
usingTriangleFan:(BOOL)usingTriangleFan __attribute__((deprecated("已废弃")));
/**
* @brief 使OpenGLES
* @param textureID OpenGLES纹理ID
* @param points OpenGLES坐标系点指针,, ,- (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
*/
- (void)renderIconWithTextureID:(GLuint)textureID points:(CGPoint *)points __attribute__((deprecated("已废弃")));
/**
* @brief 使OpenGLES
* @param textureID OpenGLES纹理ID
* @param points OpenGLES坐标系点指针,, ,- (CGPoint)glPointForMapPoint:(MAMapPoint)mapPoint, - (CGPoint *)glPointsForMapPoints:(MAMapPoint *)mapPoints count:(NSUInteger)count
* @param modulateColor , = * modulateColor. alpha的话就设置为[red=1, green=1, blue=1, alpha=0.5]
*/
- (void)renderIconWithTextureID:(GLuint)textureID points:(CGPoint *)points modulateColor:(UIColor *)modulateColor __attribute__((deprecated("已废弃")));
/**
* @brief ()
*/
- (void)glRender;
/**
* @brief ID存储在成员strokeTextureID中nil时
* @param textureImage 2nil
* @return openGL纹理ID, 0
*/
- (GLuint)loadStrokeTextureImage:(UIImage *)textureImage __attribute__((deprecated("已废弃, 请通过属性strokeImage设置")));
/**
* @brief since 5.1.0
* @param textureImage 2)
* @return openGL纹理ID, 0
*/
- (GLuint)loadTexture:(UIImage *)textureImage;
/**
@brief since 5.1.0
@param textureId ID
*/
- (void)deleteTexture:(GLuint)textureId;
/**
* @brief overlay对象有更新时. since 5.0.0
*/
- (void)setNeedsUpdate;
@end