国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ArcgisAPIForIOS擴展AGSDynamicLayer新舊版API對比

2019-11-14 19:47:02
字體:
來源:轉載
供稿:網友
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版本進行相關方法重載。

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 民勤县| 宁津县| 漯河市| 巍山| 沭阳县| 自治县| 平江县| 临漳县| 龙口市| 大竹县| 青神县| 九江市| 阳谷县| 宝应县| 屯留县| 宝兴县| 舟山市| 武清区| 固始县| 双鸭山市| 玉门市| 柘荣县| 梓潼县| 西昌市| 威宁| 射阳县| 阿鲁科尔沁旗| 云和县| 积石山| 淳安县| 陇川县| 遵义县| 肇庆市| 扬州市| 巩义市| 望谟县| 阿克陶县| 饶阳县| 文化| 留坝县| 镶黄旗|