【iOS】Arcgis API For IOS扩展AGSDynamicLayer新旧版API对比
来源:互联网 发布:龙江网络佳木斯分公司 编辑:程序博客网 时间:2024/06/05 04:47
转载自 http://www.bkjia.com/IOSjc/924934.html
AGSDynamicLayer(ForSubclassEyesOnly) Category ReferenceDescriptionThis category organizes the methods that are relevant to subclassing a dynamic layer. Developer can create custom dynamic layers by paying special attention to the methods in this category when subclassing AGSDynamicLayer.Sub-classes must provide valid values for AGSLayer::spatialReference, AGSLayer::fullEnvelope, and AGSLayer::initialEnvelope properties. Other properties on AGSLayer are optional.Since 10.1.1 See also AGSLayer(ForSubclassEyesOnly) Instance Methods(void) - requestImageWithWidth:height:envelope:timeExtent: (void) - setImageData:forEnvelope: PropertiesNSOperationQueue * queue BOOL wrapAroundSupported
1、根据新版API(Since10.1.1)看到实例方法已改变,所以需要重写对应的方法requestImageWithWidth:height:envelope:timeExtent:和setImageData:forEnvelope:;
2、不啰嗦,新版扩展代码参考贴上:
#import "CustomDynamicLayer.h"@interface CustomDynamicLayer ()@property (nonatomic, strong, readwrite) AGSEnvelope *fullEnvelope;@property (nonatomic, strong, readwrite) AGSSpatialReference *spatialReference;@end@implementation CustomDynamicLayer@synthesize fullEnvelope = _fullEnvelope;@synthesize spatialReference = _spatialReference;#pragma mark - Init Methods- (id)initWithFullEnvelope:(AGSEnvelope*)fullEnvelope { self = [super init]; if (self) { _spatialReference = fullEnvelope.spatialReference; _fullEnvelope = fullEnvelope; [self layerDidLoad]; } return self;}#pragma mark - Request Image-(void)requestImageWithWidth:(NSInteger)width height:(NSInteger)height envelope:(AGSEnvelope*)env timeExtent:(AGSTimeExtent*)timeExtent { // get an image,实际项目中有NameID,URL等形式来表达UIImage, // 如UIImage* img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imgUrl]]]; UIImage *img = [UIImage imageNamed:@"esri_campus"]; // if request envelope instersect with full envelope // of layer then only set image data if ([env intersectsWithEnvelope:self.fullEnvelope]) { [self setImageData:UIImagePNGRepresentation(img) forEnvelope:self.fullEnvelope]; } else { [self setImageData:nil forEnvelope:self.fullEnvelope]; }}@end
3、旧版API方法有差异,通过《AGSDynamicLayerDrawingOperation》类扩展,源码:
#import "CustomDynamicLayer.h"@class AGSLayers;@implementation CustomDynamicLayer@synthesize URL=_URL,imageId=_imageId,envelope=_envelope;#pragma mark - Init- (id)initWithURL:(NSURL*)url imageId:(NSString*)imageId envelope:(AGSEnvelope*)envelope { if (self = [self init]) { self.URL = url; self.imageId = imageId; self.envelope = _envelope; _loaded = YES; } return self;}#pragma mark - - (AGSUnits)units { return AGSUnitsUnknown;}- (AGSSpatialReference*) spatialReference { return self.envelope.spatialReference;}- (AGSEnvelope*)fullEnvelope { return self.envelope;}- (AGSEnvelope*)initialEnvelope { return self.envelope;}#pragma mark AGSDynamicLayer- (void)imageRequestOperation:(NSOperation<AGSDynamicLayerDrawingOperation>*)op didGetImage:(UIImage *)image { NSLog(@"image: %@",image); [self.exportDelegate dynamicLayer:self exportMapImageOperation:op didFinishWithImage:image];}- (void)imageRequestOperation:(NSOperation<AGSDynamicLayerDrawingOperation>*)op didFailWithError:(NSError *)error { NSLog(@"Error: %@",error); if ([self.exportDelegate respondsToSelector:@selector(dynamicLayer:exportMapImageOperation:didFailWithError:)]) { [self.exportDelegate dynamicLayer:self exportMapImageOperation:op didFailWithError:error]; }}-(NSOperation<AGSDynamicLayerDrawingOperation>*)exportMapImage:(AGSExportImageParams*)exportImageParams { if (exportImageParams.envelope == nil || CGSizeEqualToSize(CGSizeZero, exportImageParams.size)) { return nil; } NSMutableDictionary *exportParams = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"png", @"type", self.imageId, @"id", nil]; AGSDynamicLayerImageRequestOperation *operation = [[AGSDynamicLayerImageRequestOperation alloc] initWithURL:self.URL resource:@"" queryParameters:exportParams]; operation.target = self; operation.action = @selector(imageRequestOperation:didGetImage:); operation.errorAction = @selector(imageRequestOperation:didFailWithError:); operation.exportImageParams = exportImageParams; [[AGSRequestOperation sharedOperationQueue] addOperation:operation]; return [operation autorelease];}#pragma mark - dealloc-(void)dealloc{ self.URL = nil; self.imageId = nil; self.envelope = nil; [super dealloc];}@end
内容供参考。
目前针对JS\FLEX\Android\IOS都有调用在线地图、天地图等情况,需要根据对应的API版本进行相关方法重载。
0 0
- 【iOS】Arcgis API For IOS扩展AGSDynamicLayer新旧版API对比
- ArcGIS API for iOS 中的几何对象
- 【iOS】ArcGIS API For iOS 实现图层显示控制
- ArcGIS API for iOS开发教程三 使用MapView
- ArcGIS API for iOS开发教程四 使用GraphicsLayer
- ArcGIS API for iOS开发教程(五)数据查询
- 成功使用ArcGIS API for iOS加载Google地图
- ArcGIS API for iOS开发教程六 使用GP服务
- ArcGIS API for iOS开发教程(七)Geometry Service
- ArcGIS API for iOS开发教程(八)地图定位
- ArcGIS API for iOS v1.8 beta 发布
- ArcGIS API for iOS在俄勒冈大学校园中的创新应用
- ArcGIS API For IOS 实现图层显示控制
- arcgis api for IOS版本更新
- searchAPI(iOS 9新api)
- ArcGIS API for Flex (使用ArcGIS API for Flex 创建一个新的地图项目)
- MapABC API for iOS 文档
- API Design for ios 译文
- J2EE框架Jar包说明及各框架下的Jar包依赖关系(二)
- 祝贺诺博源软件签订新三板挂牌上市合同
- Media Foundation学习笔记(六)Media Foundation的架构 Media Session
- 山
- 机器人终将改变世界
- 【iOS】Arcgis API For IOS扩展AGSDynamicLayer新旧版API对比
- Media Foundation学习笔记(七)Media Foundation的架构 Source Reader
- HDU-1050 Moving Tables 贪心
- poj_2513
- openstack (neutron)无法删除已创建的网络
- CAShapeLayer的简介
- J2EE框架Jar包说明及各框架下的Jar包依赖关系(一)
- Socket编程实践(12) --UDP编程基础
- Spring中ApplicationContext和beanfactory区别