swinfield

Zoom to Location using X, Y....

Discussion created by swinfield on Sep 20, 2010
Latest reply on Oct 27, 2010 by swinfield
I'm trying to do a simple zoom to a point using AGSPoint (only providing an x, y)...I can't get it to zoom.  In addition, I'm getting an error stating, " 'AGSMapView' may not respond to -showCalloutAtPoint:forGraphic:' "  I've attached the method used to zoom....can anyone provide any insight for me? 
//clear previous results
[self.graphicsLayer removeAllGraphics];

double xPoint = [[xCoords objectAtIndex:0] doubleValue];
double yPoint = [[yCoords objectAtIndex:0] doubleValue ];
AGSPoint *pt = [[AGSPoint alloc] initWithX:xPoint y:yPoint spatialReference:self.mapView.spatialReference] ;




//we have one result, center at that point
[self.mapView centerAtPoint:pt animated:YES];


AGSMutableEnvelope *extent = [AGSMutableEnvelope envelopeWithXmin:pt.x ymin:pt.y xmax:pt.x+10 ymax:pt.y+10 spatialReference:self.mapView.spatialReference];

[extent expandByFactor:30];
[self.mapView zoomToEnvelope:extent animated:YES];


//create a marker symbol to use in our graphic
AGSPictureMarkerSymbol *marker = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"BluePushpin.png"];

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

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

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

//because we alloc'ed and init'ed the callout, release it.
[calloutTemp release]; 

//add the graphic to the graphics layer
[self.graphicsLayer addGraphic:graphic];    

// set the width of the callout
self.mapView.callout.width = 250;  

//show the callout
[self.mapView showCalloutAtPoint:(AGSPoint *)graphic.geometry forGraphic:graphic]; 
[graphic release];

//since we've added graphics, make sure to redraw
[self.graphicsLayer dataChanged]; 

}

Outcomes