AGSDynamicLayer(ForSubclassEyesOnly) Category Reference
Description This 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: Properties
NSOperationQueue * 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版本进行相关方法重载。

Arcgis API For IOS扩展AGSDynamicLayer新旧版API对比的更多相关文章

  1. (转)Resources和AssetBundle(新旧版)学习

    Resources:   Resources的缺点:1.与显示Inspector上直接引用相比,Resources使用不方便.     2.不管你Resources上的资源是否调用了,当你发布的时候, ...

  2. JavaScript 兼容新旧版chrome和firefox的桌面通知

    1.新/旧版本的chrome和firefox都可支持,IE下不支持因此设置为了在最小化窗口处闪烁显示提示文字. 2.设置为提示窗口显示5秒即关闭. 3.可设置图标和点击提示窗口要跳转到的页面(见输入参 ...

  3. 旧版API的TextInputFormat源码分析

    TextInputFormat类 package org.apache.hadoop.mapred; import java.io.*; import org.apache.hadoop.fs.*; ...

  4. 新旧版ubuntu镜像免费下载

    链接:https://pan.baidu.com/s/1hUNfiyA_Npj9QQ0vNLJ_Xw 密码:6k6i

  5. Why containers? Why should we care? 新旧容器的对比

    https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/ The Old Way to deploy applications ...

  6. 三、create-react-app新旧版中使用less和antd并修改主题颜色

    引入less 如果项目根目录中没有config文件夹,首先暴露出项目配置文件,项目下执行: npm run eject 如果项目是从git仓库中pull下来的的话,必须确保本地项目与仓库中没有冲突,才 ...

  7. mapreduce新旧api对比

    对比:hadoop版本1.x 新版,hadoop版本0.x 旧版 1.新api引用包一般是mapreduce ,旧版api引用的包一般是mapred 2.新api使用Job,旧版api使用JobCon ...

  8. HIVE: 自定义TextInputFormat (旧版MapReduceAPI ok, 新版MapReduceAPI实现有BUG?)

    我们的输入文件 hello0, 内容如下: xiaowang 28 shanghai@_@zhangsan 38 beijing@_@someone 100 unknown 逻辑上有3条记录, 它们以 ...

  9. 最流行的JavaScript库jQuery不再支持旧版IE

    直到JQuery2.0的发布,流行的jQuery JavaScript库到了一个重要里程碑.2.0版本比前任版本在大小上缩减了12%,但是更大的新闻是,jQuery 2.0不在对IE6,7,8三个版本 ...

随机推荐

  1. error-2015-9-9

    类型的建键部分无效,该键的所有部分均不可为null 映射从第行开始的片段时有问题 表的键具有潜在运行时冲突 列映射到概念端的属性 但是它们未形成entitySet的键属性 报错: 未能加载文件或程序集 ...

  2. iOS(本地通知与远程通知)

    iOS 推送通知有两种:本地推送.远程推送. 本地推送 :  在不需要联网的情况下,由APP发出推送,常用于某一时刻的通知,如闹钟.本地通送有局限性在于当APP处于后台或者退出时就无法发出通知. 远程 ...

  3. 使用HttpClient 发送get、post请求,及其解析xml返回数据

    一.关于HttpClient的使用: 可以参考这个博客地址,这里有详细的介绍,需要的可以先看一下: 地址是:http://blog.csdn.net/wangpeng047/article/detai ...

  4. sugar 自动为DP 加cache (or打表)

    // from http://www.csdn.net/article/2015-12-03/2826381 #include <iostream> #include <tuple& ...

  5. Fiddler抓包之IOS

    Fiddler是一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的"进出"Fiddler的数据(指cookie,html,j ...

  6. Synchronized和Static Synchronized区别

    通过分析这两个用法的分析,我们可以理解Java中锁的概念. 一个是实例锁(锁在某一个实例对象上,如果该类是单例,那么该锁也具有全局锁的概念), 一个是全局锁(该锁针对的是类,无论实例多少个对象,那么线 ...

  7. MM常用BADI

    1.删除采购申请BADI BAPI_REQUISITION_DELETE 但是需要输入采购申请 和采购申请行项目号

  8. 合并两个排好序的链表(c++)

    #include<iostream> struct node{ int payload; node* next; node(int payload){this->payload=pa ...

  9. unity3d笔记:控制特效的播放速度

           一般在游戏中,主角或者怪物会受到减速效果,或者攻击速度减慢等类似的状态.本身动作减速的同时,衔接在角色上的特效也需要改变相应的播放速度.一般特效有三个游戏组件:   关键点就是改变Ani ...

  10. 利用Maple推导向量方程的微分公式

    在某些几何软件的开发中,会要求写出一个向量方程的微分公式.对我而言,手工推导繁琐.易出错.且需要反复校验. 早就听说Mathematica, Maple这样的软件可以自动进行符号公式的推导,一直没有时 ...