Callouts appear at 0,0

585
2
Jump to solution
08-27-2012 08:56 AM
ChrisRiver
New Contributor III
Hi,

I'm trying to programmatically display a callout based on and AGSGraphic object selected in a table view (i.e.

// initial map / layer setup AGSTiledMapServiceLayer *tiledLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:[NSURL URLWithString:@MAP_SERVER]]; AGSEnvelope *env = [[AGSEnvelope alloc]                         initWithXmin:INITIAL_XMIN                         ymin:INITIAL_YMIN                         xmax:INITIAL_XMAX                         ymax:INITIAL_YMAX                         spatialReference:[AGSSpatialReference spatialReferenceWithWKID:102100]];      [self.mapView addMapLayer:tiledLayer withName:@"Tiled Layer"]; [self.mapView zoomToEnvelope:env animated:NO]; [self.mapView setCalloutDelegate:self];   // user taps on search result  AGSGraphic *g = [self.featureSet.features objectAtIndex:indexPath.row]; [self.mapView showCalloutAtPoint:nil forGraphic:g animated:NO];


)

This always results in the callout displaying at x:0, y:0.

After searching the forums (and google) I have made sure that my spatialReferences line up, but it doesn't make any difference.  Is there something obvious I am missing?

Thanks for any help.

Chris
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Chris,

Change,
[self.mapView showCalloutAtPoint:nil forGraphic:g animated:NO];
To
[self.mapView showCalloutAtPoint:g.geometry.envelope.center forGraphic:g animated:NO];

This should fix it.

Regards,
Nimesh

View solution in original post

0 Kudos
2 Replies
NimeshJarecha
Esri Regular Contributor
Chris,

Change,
[self.mapView showCalloutAtPoint:nil forGraphic:g animated:NO];
To
[self.mapView showCalloutAtPoint:g.geometry.envelope.center forGraphic:g animated:NO];

This should fix it.

Regards,
Nimesh
0 Kudos
ChrisRiver
New Contributor III
Thank you!
0 Kudos