Select to view content in your preferred language

Application crash on drowing Picture Marker Symbol

1690
4
06-27-2011 01:40 AM
FaisalSabri
Emerging Contributor
Hi ,

i'm using "did click at point" to draw my Picture Symbol on the clicked point ,

my problem is the following :

- if i clicked anywhere in the map , i add the symbol to graphic layer and draw it without any problem , but if i clicked at the same location that i have already clicked before the application will crash ,

- some times before the application crash , a small dialog with a blue arrow shows up on the picture symbol , how to disable that dialog and why the application is crashing ??

below is my code and attached image for the blue arrow :



if (Clicked == NO)
{
self.view.userInteractionEnabled = FALSE;

HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];

HUD.delegate = self;
HUD.labelText = @"Ù?رجÙ? اÙ?اÙ?تظار";

[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];


[myGraphicsLayer removeAllGraphics];

AppDataObjectHelper* theDataObject = [self theAppDataObject];

point = mappoint;

theDataObject.XPoint = [NSString stringWithFormat:@"%.11lf",mappoint.x];
theDataObject.YPoint = [NSString stringWithFormat:@"%.11lf",mappoint.y];

url = [NSURL URLWithString:theDataObject.StreetLayerIndex];

IsStreetLayer = YES;

[self GetQuery:url mapPoint:point];


NSLog(@"touchesBegan");

//create the callout template, used when the user displays the callout
AGSCalloutTemplate *calloutTemp = [[AGSCalloutTemplate alloc]init];

marker = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"pushpin.png"];

marker.xoffset = 5;
marker.yoffset = 5;
marker.hotspot = CGPointMake(-9, -11);

//create the graphic
AGSGraphic *graphic = [[AGSGraphic alloc] initWithGeometry:mappoint symbol:marker
attributes:nil infoTemplateDelegate:calloutTemp];

[calloutTemp release];


[myGraphicsLayer addGraphic:graphic];


self.mapView.callout.width = 250;

[graphic release];

[myGraphicsLayer dataChanged];

Clicked = YES;
}
0 Kudos
4 Replies
MuratDzhusupov
Emerging Contributor
You wrote


... a small dialog with a blue arrow shows up on the picture symbol , how to disable that dialog ...

//create the callout template, used when the user displays the callout
AGSCalloutTemplate *calloutTemp = [[AGSCalloutTemplate alloc]init];
.....
//create the graphic
AGSGraphic *graphic = [[AGSGraphic alloc] initWithGeometry:mappoint symbol:marker
attributes:nil infoTemplateDelegate:calloutTemp];



This small dialog is callout (see more information on http://help.arcgis.com/en/arcgismobile/10.0/apis/ios/1.8/concepts/index.html#/Displaying_a_Callout/0...)

If you set nil instead of calloutTemp then (I think) graphic will be without callout functionality (user cannot see any callout after touch graphic on map)

//create the graphic without callout functionality
AGSGraphic *graphic = [[AGSGraphic alloc] initWithGeometry:mappoint symbol:marker
attributes:nil infoTemplateDelegate:calloutTemp];
0 Kudos
FaisalSabri
Emerging Contributor
Thank You !!

now is working perfect :))
0 Kudos
NimeshJarecha
Esri Regular Contributor
Faisal,

The real problem is that you are creating a local variable of AGSCalloutTemplate (AGSCalloutTemplate *calloutTemp = [[AGSCalloutTemplate alloc]init]). Also, you are explicitly releasing it instead of retaining. After adding the graphic to graphic layer when you tap on it, the callout which added to the graphic is no longer available and hence it crashes.

You must create an instance variable of AGSCalloutTemplate with retain property to get it to work. Please have a look at code of available samples for the same.

Regards,
Nimesh
0 Kudos
FaisalSabri
Emerging Contributor
Dear Nimesh,

yes i noticed That , i need to read more on ESRI and iOS , without just downloading the sample and try to understand them ... the solution is in front of my eye but i'm not reading it !! :((((

Thank u Nimesh
0 Kudos