IOS Touch and CallOut

3400
6
Jump to solution
08-02-2012 08:48 AM
FaizanTayyab
Occasional Contributor
Hi All,

I am new to esri IOS programming. I have a mapview with a basemap and a dynamic layer. I am trying to display a callout with information from the dynamic layer.

I have made use of touchDelegate and it is invoking the didClickAtPoint method however when i click on the dynamic layer, the graphics arguments of the didClickAtPoint contains nothing.

is there any step i am missing. Can anyone guide me please.

Thanks
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
If you are using ARC then you should create property with 'strong' keyword.

in .h file
@property (nonatomic, strong) AGSIdentifyTask *task;

in .m file
@synthesize task;
self.task=[[AGSIdentifyTask alloc]initWithURL:petroURL];

Regards,
Nimesh

View solution in original post

0 Kudos
6 Replies
NimeshJarecha
Esri Regular Contributor
Okay..let me explain few things...

1. Dynamic layer is just an IMAGE not a GRAPHIC which you click and get he information. Please go through ArcGIS Dynamic Map Service Layer document.
2. If you want to show the information for a feature in a dynamic layer then you will have to request it from server by either executing query task or identify task. They will return result as graphics. Which you suppose to add to the graphics layer and then on click of that graphic you can show the callout and detail.
3. If you want directly graphics in map then use AGSFeatureLayer instead of AGSDynamicMapServiceLayer. On click of a feature of feature layer you'll see callout and show further detail.

Hope this helps!

Regards,
Nimesh
0 Kudos
FaizanTayyab
Occasional Contributor
Thanks the for reply. I have the following code but i am not getting any results neither it is failing. Is something wrong in the code below?


-(void) mapView:(AGSMapView *)mapView didClickAtPoint:(CGPoint)screen mapPoint:(AGSPoint *)mappoint graphics:(NSDictionary *)graphics{
    
    NSURL *petroURL=[[NSURL alloc]initWithString:@"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"];
    //AGSIdentifyTask *task=[AGSIdentifyTask identifyTaskWithURL:petroURL];
    AGSIdentifyTask *task=[[AGSIdentifyTask alloc]initWithURL:petroURL];
    [task setDelegate:self];
    AGSIdentifyParameters *param=[[AGSIdentifyParameters alloc]init];
    param.layerIds=[NSArray arrayWithObjects:[NSNumber numberWithInt:5], nil];
    param.tolerance=5;
    param.geometry=mappoint;
    param.size=self.mapView.bounds.size;
    AGSEnvelope *env=[[AGSEnvelope alloc]initWithXmin:-10948000 ymin:-6624000 xmax:9794000 ymax:7406000 spatialReference:self.mapView.spatialReference];
    param.mapEnvelope=env;
    param.returnGeometry=YES;
    param.layerOption=AGSIdentifyParametersLayerOptionAll;
    param.spatialReference=self.mapView.spatialReference;
    [task executeWithParameters:param];
    
}
-(void) identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results{
    
    NSLog(@" %@ ",[results count]);
}
0 Kudos
NimeshJarecha
Esri Regular Contributor
It's not getting any result because AGSIdentifyTask is getting released. Create a retain property for "AGSIdentifyTask *task" and then try.

Regards,
Nimesh
0 Kudos
FaizanTayyab
Occasional Contributor
It's not getting any result because AGSIdentifyTask is getting released. Create a retain property for "AGSIdentifyTask *task" and then try.

Regards,
Nimesh


As i am using ARC i am getting an error while using

[task retain]


I thought that using alloc, there is not need to retain.

Thanks
0 Kudos
NimeshJarecha
Esri Regular Contributor
If you are using ARC then you should create property with 'strong' keyword.

in .h file
@property (nonatomic, strong) AGSIdentifyTask *task;

in .m file
@synthesize task;
self.task=[[AGSIdentifyTask alloc]initWithURL:petroURL];

Regards,
Nimesh
0 Kudos
FaizanTayyab
Occasional Contributor
If you are using ARC then you should create property with 'strong' keyword.

in .h file
@property (nonatomic, strong) AGSIdentifyTask *task;

in .m file
@synthesize task;
self.task=[[AGSIdentifyTask alloc]initWithURL:petroURL];

Regards,
Nimesh


That worked!!!

Thanks alot
0 Kudos