Order of fields in AGSPopupInfo

2175
3
Jump to solution
02-23-2012 08:51 PM
c_f_ong
New Contributor III
Hello

I've set up the graphic's attributes as follows:

        NSMutableDictionary *attribs = [NSMutableDictionary dictionaryWithObject:@"title" forKey:@"title"];
        [attribs setValue:@"subtitle" forKey:@"subtitle"];
        NSString *strX = [NSString stringWithFormat:@"%lf", pt.x];
        NSString *strY = [NSString stringWithFormat:@"%lf", pt.y];
        [attribs setValue:strX forKey:@"x"];
        [attribs setValue:strY forKey:@"y"];
        graphic = [[AGSGraphic alloc] initWithGeometry:pt
                                                symbol:marker
                                            attributes:attribs
                                  infoTemplateDelegate:self.CalloutTemplate];
        [self.graphicsLayer addGraphic:graphic];

Hence, the order of graphic's attributes is as follows:

title
subtitle
x
y

However, the order of fields as per the code below doesn't follow the same as the above graphic's attributes.

    AGSPopupInfo *info = [AGSPopupInfo popupInfoForGraphic:graphic];

Instead the order is as follows:

title
y
x
subtitle

Anyone with a clue as to why the change in order of fields? How to make AGSPopupInfo follow the same order as the graphic's attributes?

Thanks.

Rgds
Ong CF
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Great! Please mark thread as answered! 🙂

Regards,
Nimesh

View solution in original post

0 Kudos
3 Replies
NimeshJarecha
Esri Regular Contributor
You are trying to create a popupInfo for a graphic in a graphics layer and not in feature layer. Hence, you cannot control the order of the fields. If you want to maintain the order than you should set desired AGSPopupFieldInfo's array in AGSPopupInfo::fieldInfos.

Like this..

1. Create a new mutable array.
2. Read each record of popupInfo.fieldInfos and add in the new array in desired order.
3. Set new mutable array to popupInfo.fieldInfos

Hope this helps...

Regards,
Nimesh
0 Kudos
c_f_ong
New Contributor III
Hi Nimesh

You're right - problem is with the graphic's attributes, i.e. their order is not determined by sequence of adding objects to the NSMutableDictionary.

Thanks for your suggestion. I've to reorder fieldInfos according to the keys in graphic's attributes for fieldName to appear in the correct sequence in AGSPopupsContainerViewController.

Problem solved & many thanks!

Rgds
Ong CF
0 Kudos
NimeshJarecha
Esri Regular Contributor
Great! Please mark thread as answered! 🙂

Regards,
Nimesh
0 Kudos