+ Reply to Thread
Results 1 to 6 of 6

Thread: zoom to graphics layer selected

  1. #1
    Luca Alferi
    Join Date
    Apr 2012
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default zoom to graphics layer selected

    Hi
    i have a problem
    I developed an application that allows you to query a layer Dynamics. I would like to center the selected feature in the map.
    Help me
    thanks

  2. #2
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    882
    Points
    493
    Answers Provided
    106


    0

    Default Re: zoom to graphics layer selected

    You can get the geometry of the selected feature and use AGSMapView's zoomToGeometry method to zoom to it.

    Regards,
    Nimesh

  3. #3
    Jerry Chapman
    Join Date
    Nov 2011
    Posts
    13
    Points
    1
    Answers Provided
    0


    0

    Default Re: zoom to graphics layer selected

    Hi Luca,

    I'm fairly new at this, but this is how I did mine.

    Code:
    #pragma mark AGSQueryTaskDelegate
    
    //results are returned
    - (void)queryTask:(AGSQueryTask *)queryTask operation:(NSOperation *)op didExecuteWithFeatureSetResult:(AGSFeatureSet *)featureSet 
    {
        if ([featureSet.features count] == 0) 
        {
        	UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                                message:@"Address not Found"
                                                               delegate:nil
                                                      cancelButtonTitle:@"OK"
                                                      otherButtonTitles:nil];
            [alertView show];
        }
        else
        {
            AGSGraphic *graphic = [featureSet.features objectAtIndex:0];
            AGSMutablePoint *pt = [graphic.geometry.envelope.center mutableCopy];
            AGSMutableEnvelope *env = [graphic.geometry.envelope mutableCopy];
            
            if (featureSet.geometryType == AGSGeometryTypePoint)
            {
                NSLog(@"point type");
                float xMin = pt.x - 150.0;
                float yMin = pt.y - 150.0;
                float xMax = pt.x + 150.0;
                float yMax = pt.y + 150.0;
                AGSSpatialReference *sref = graphic.geometry.envelope.spatialReference;
                AGSEnvelope *envAlt = [AGSEnvelope envelopeWithXmin:xMin ymin:yMin xmax:xMax ymax:yMax spatialReference:sref];
                [self.mapView zoomToEnvelope:envAlt animated:YES];            
            }
            else
            {
                [env expandByFactor:1.3];
                [self.mapView zoomToEnvelope:env animated:YES];
            }
        }
    }

  4. #4
    Luca Alferi
    Join Date
    Apr 2012
    Posts
    18
    Points
    0
    Answers Provided
    0


    0

    Default Re: zoom to graphics layer selected

    Sorry
    i'm a beginner. How can i get geometry of graphics Layer?
    Please an example code

  5. #5
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    882
    Points
    493
    Answers Provided
    106


    0
    This post is marked as the answer

    Default Re: zoom to graphics layer selected

    Have a look at Graphics Sample.

    Regards,
    Nimesh

  6. #6
    Nimesh Jarecha

    Join Date
    Oct 2009
    Posts
    882
    Points
    493
    Answers Provided
    106


    1

    Default Re: zoom to graphics layer selected

    Luca,

    If this issue is resolved then please mark thread as answered.

    Regards,
    Nimesh

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts