AGSGraphicsLayer unique render values in leged

4730
6
04-12-2016 02:18 PM
MaximoMobile
New Contributor

I am trying to get the  unique render values in legend but its giving me an error , i can't get images for unique values in render  , any help would be appreciated.

0 Kudos
6 Replies
SuganyaBaskaran1
Esri Contributor

What error are you getting? Can you post your code so I can take a look? Thanks.

Suganya

0 Kudos
MaximoMobile
New Contributor

I know i am doing something wrong , dont know where though , i want individual images for legend but its not coming and its crashing the app

+ (AGLegendInfo*)infoForGraphicsLayer:(AGSGraphicsLayer*)layer

{

    AGLegendInfo *legendInfo = [[AGLegendInfo alloc] init];

    NSMutableArray *legendInfos = [[NSMutableArray alloc] init];

    AGSRenderer *renderer = layer.renderer;

    AGLegendInfoType *info = [[AGLegendInfoType alloc] init];

    AGSGraphic *g = [[AGSGraphic alloc]init];

    UIImage *image = [[UIImage alloc]init];

   

    if ([layer.renderer isKindOfClass:[AGSUniqueValueRenderer class]])

    {

        NSLog(@"AGSUniqueValueRenderer");

        AGSUniqueValueRenderer *renderer = (AGSUniqueValueRenderer *)layer.renderer;

        int num = [renderer.uniqueValues count];

        NSLog(@"%d", num);

       

        for (int j = 0 ; j < num ; j++)

        {

            AGSUniqueValue *value = [renderer.uniqueValues objectAtIndex:j];

            g = [layer.graphics objectAtIndex:j];

            image = [renderer swatchForFeature:g size:CGSizeMake(20, 30)];

            legendInfo.defaultSymbol = image;

            [legendInfos addObject:legendInfo];

           

        }

            //[legendInfos addObject:legendInfo];

            legendInfo.defaultSymbol = image;

            legendInfo.layerName = layer.name;

            legendInfo.types = [[NSArray alloc] initWithArray:legendInfos];

       

    return legendInfo;

    }

0 Kudos
MaximoMobile
New Contributor

after number iterations  , i am still getting this error

'NSInvalidArgumentException', reason: '-[AGLegendInfo typeName]: unrecognized selector sent to instance 0x7fec1b790380'

does any one have steps to get the unique render legend from graphics layer , i could not get  images using swatchForFeature for values in unique render , i dont know which graphics i should send to get the image

any idea???? please

0 Kudos
SuganyaBaskaran1
Esri Contributor

I see you are using AGLegendInfo class. Is that meant to be AGSLegendInfo?

Which version of the SDK are you using (or intend to use)? I ask because AGSLegendInfo class is present only in the Quartz beta release and AGSGraphicLayer is in 10.2.5 (AGSGraphicsOverlay in Quartz)

0 Kudos
MaximoMobile
New Contributor

no its not AGSLegendinfo , I have create my own class. the issue is the

render does not send all the types in.

but requirement has change now as users want those render values as a layer

that they can turn on and off

So I have to create individual layers for those render value. you may

solve my other issue , can i create a dynamic variable for

AGSGraphicsLayer

like i have to create all these AGSGraphicsLayer with different type of

statuses

AGSGraphicsLayer* APPRmyGraphicsLayer = [AGSGraphicsLayer

graphicsLayer];

AGSGraphicsLayer* COMPmyGraphicsLayer = [AGSGraphicsLayer

graphicsLayer]; ... and so on

why i cant do something like

NSSet *uniqueStatus = [NSSet setWithArray:[objects valueForKey:@"status"

]];

int numElement = uniqueStatus.count;

NSMutableArray *gr = [[AGSGraphicsLayer alloc]init];

for (NSString *item in uniqueStatus) {

;

}

or

for (NSString *item in uniqueStatus)

{

AGSGraphicsLayer *gr = [[AGSGraphicsLayer alloc] init];

;

;

NSLog(gr.name);

}

both gives me an error , the layer gets added to map but i cant add

geometry to it as its not an unique name layers

0 Kudos
SuganyaBaskaran1
Esri Contributor

Please send a sample project that would reproduce the issue so we can take a look.

0 Kudos