Comparison between new and old versions of API of Arcgis API For IOS extension AGSDynamicLayer, arcgisios

Source: Internet
Author: User

Comparison between new and old versions of API of Arcgis API For IOS extension AGSDynamicLayer, arcgisios

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. According to the new version of API (Since10.1.1), we can see that the instance method has changed. Therefore, we need to rewrite the corresponding method requestImageWithWidth: height: envelope: timeExtent: And setImageData: forEnvelope :;

2. Don't worry. Refer to the new version extension code:

# 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) Principal :( 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. The actual project contains NameID, URL, and other forms to express UIImage,
// Such as 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. There are differences between the old API methods, which are extended through the class AGSDynamicLayerDrawingOperation. Source Code:

#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

Content for reference.

Currently, JS, FLEX, Android, and IOS require method overloading based on the corresponding API version.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.