Displaying Callouts Directly from the Feature Service Layer

3613
3
Jump to solution
01-30-2012 09:27 AM
MasonMalcik
New Contributor II
I'm a newbie at developing iOS applications with the ArcGIS SDK, and so far, my application has running smoothly, apart from the lack of callouts.  I have several dynamic feature service layers that I am using, which are displaying in the map view without any problems. However I cannot find any information on how to display the callouts directly from the feature layers displayed.  Is there a way to do this? 
Every tutorial and reference guide I see seems to suggest I have to create a separate graphics layer for the features first, then run a task in order to get information for the callout.  I would much appreciate a way of getting around this, if that is even possible.
0 Kudos
1 Solution

Accepted Solutions
MasonMalcik
New Contributor II
For those of you who may be interested, I figured it out.

First, I adopted these delegates in my interface file:

<AGSMapViewLayerDelegate> <AGSMapViewCalloutDelegate> < AGSMapViewTouchDelegate>


Then, I set the delegates, added the Feature Layer, created a template for the title and detail text in the callout, and assigned the template to the feature layer

// Set the Layer Delegate self.mapView.layerDelegate = self;      // Set the Callout Delegate self.mapView.calloutDelegate = self;      // Set the Touch Delegate self.mapView.touchDelegate = self;   //-----------------Create and Add Feature Layer-------------------------     NSURL* myUrl = [NSURL URLWithString: @"<place feature service URL here>"];       AGSFeatureLayer* myLayer = [AGSFeatureLayer featureServiceLayerWithURL: myUrl mode: AGSFeatureLayerModeOnDemand];          // Add My Dynamic Feature Layer to Map View     [self.mapView addMapLayer:myLayer withName:@"My Layer"];              // Create Info Template Delegate for My Dynamic Feature Layer     AGSCalloutTemplate* myTemplate = [[AGSCalloutTemplate alloc] init] ;     myTemplate.titleTemplate = @"${Field Value for Title Text}";       myTemplate.detailTemplate = @"${Field Value for Detail Text}";            // Assign Template to My Dynamic Feature Layer     myLayer.infoTemplateDelegate = myTemplate;


I hope this helps anyone having a similar issue

View solution in original post

0 Kudos
3 Replies
MasonMalcik
New Contributor II
For those of you who may be interested, I figured it out.

First, I adopted these delegates in my interface file:

<AGSMapViewLayerDelegate> <AGSMapViewCalloutDelegate> < AGSMapViewTouchDelegate>


Then, I set the delegates, added the Feature Layer, created a template for the title and detail text in the callout, and assigned the template to the feature layer

// Set the Layer Delegate self.mapView.layerDelegate = self;      // Set the Callout Delegate self.mapView.calloutDelegate = self;      // Set the Touch Delegate self.mapView.touchDelegate = self;   //-----------------Create and Add Feature Layer-------------------------     NSURL* myUrl = [NSURL URLWithString: @"<place feature service URL here>"];       AGSFeatureLayer* myLayer = [AGSFeatureLayer featureServiceLayerWithURL: myUrl mode: AGSFeatureLayerModeOnDemand];          // Add My Dynamic Feature Layer to Map View     [self.mapView addMapLayer:myLayer withName:@"My Layer"];              // Create Info Template Delegate for My Dynamic Feature Layer     AGSCalloutTemplate* myTemplate = [[AGSCalloutTemplate alloc] init] ;     myTemplate.titleTemplate = @"${Field Value for Title Text}";       myTemplate.detailTemplate = @"${Field Value for Detail Text}";            // Assign Template to My Dynamic Feature Layer     myLayer.infoTemplateDelegate = myTemplate;


I hope this helps anyone having a similar issue
0 Kudos
MasonMalcik
New Contributor II
In addition to those steps, it is crucial to add this line of code when you create the feature layer, in order to get all the outfields available:

self.myfeatureLayer.outFields = [NSArray arrayWithObject:@"*"];
0 Kudos
Nicholas-Furness
Esri Regular Contributor
In addition to those steps, it is crucial to add this line of code when you create the feature layer, in order to get all the outfields available:

self.myfeatureLayer.outFields = [NSArray arrayWithObject:@"*"];


Hi Mason,

It's probably also worth noting that you should consider this in the context of the data you're pulling down and the requirements of your popup. While this is certainly the easiest way to make sure you have everything at your fingertips, for data sources with many fields and/or sources that might have fields with large amounts of data in them, consider only listing the fields you want to make use of (especially if running over 3G).

Nick.
0 Kudos