Attribute Information for Dynamic Map Service

920
7
07-20-2011 11:56 AM
DuncanRager
New Contributor
Greetings,

I'm a little confused about the use of a Dynamic Map Service (DMS) for display of custom polyline symbology alongside the querying capabilities of a Feature Layer.

I have a DMS setup to display 15 different layers... the app also uses 2 checklists to reference these layers, (1) to toggle the layers' visibility and (2) to set layer definitions.

I would now like to add the function of displaying attributes about the features in an info window. It seems as if this isn't possible with a DMS, but is the purpose of Feature Layers. This problem is addressed with respect to editing in the following paragraph from ESRI's JS API Concepts page...

Selection only mode does not initially request any features. Features are added only when a selection is made. This mode is useful when you cannot or do not want to bring all features into the client, but you want to highlight one or more features for a certain reason.

For example, suppose you have a roads layer that's configured to use cartographic representations, which are not supported for display using a feature layer. You want to perform some Web editing on the roads, but that requires a feature layer. What do you do?

In this scenario, you configure a dynamic map service to show the roads, then use a feature layer with selection only mode to display just the road currently being edited. This selected road is drawn using a simple client-side symbol. Once the edit is applied, you can clear the selection and refresh the dynamic map service to see the updated roads.


Does this mean that the feature layer would be present in the map, ontop of the exact same features of the DMS, and invisible until selected, and then only appearing to be selected from the DMS?

When using selection only mode, would I need to apply the same spatial queries on the Feature Layers as I am on the layers of the DMS?

And finally, would this technique apply to simply showing attribute information in an info window as opposed to editing as the concepts page suggests?

Any comments to clear this up would be much appreciated, thank you.

DR
0 Kudos
7 Replies
StephenLead
Regular Contributor III
I have a DMS setup to display 15 different layers... I would now like to add the function of displaying attributes about the features in an info window. It seems as if this isn't possible with a DMS, but is the purpose of Feature Layers...


You can display an infoWindow when working with a Dynamic layer (without using a feature layer) by running a query when you click on the map, using the same URL for the query as you used for the Dynamic layer.

The sample here might give some pointers.

Does that help?

Steve
0 Kudos
DuncanRager
New Contributor
That does help, thank you. Does this imply that a separate query/query execution/info window would need to be created for each separate layer? Are there best practices/methods of achieving this?

Also, for the sake of discussion, how would the mechanics of a Feature Layer/DMS combination (as suggested by ESRI in my first post) work? That would be very helpful to know if I ever need to add editing capabilities to my app.

Thanks again,

DR
0 Kudos
DuncanRager
New Contributor
I'm having issues retrieving information from points and polylines, though I can retrieve attribute information from polygons just fine. My code appears below...

queryTask = new esri.tasks.QueryTask("http://server/ArcGIS/rest/services/features/MapServer/0");
  queryFilter = new esri.tasks.Query();
  queryFilter.returnGeometry = true;
  queryFilter.maxAllowableOffset = 50;
  queryFilter.outFields = ["FEAT_NAME"];
  queryFilter.geometry = evt.mapPoint;
  
  queryTask.execute(queryFilter,function(featureSet){
   if (featureSet.features.length === 1){
    showFeature(featureSet.features[0], evt);
   }
   else if (featureSet.features.length !== 0){
    alert("Please Select a Single Feature.");
   }
  });


When I query a polygon I successfully create a popup with the correct attribute information, though when I query a point or polyline (and alter the /MapServer/# and the outFields accordingly), my query returns 0 results (it is a valid query). I'm wondering if it has something to do with the spatial relationship? I've attempted to max out the maxAllowableOffset, but that doesn't seem to alter anything. Does anyone have any ideas on this?

Thanks,

DR
0 Kudos
StephenLead
Regular Contributor III
I'm having issues retrieving information from points and polylines
queryFilter.geometry = evt.mapPoint;



I think this is because the geometry of the query is a single XY location - unless you happen to hit exactly on the point or line feature, it won't return any results.

You could try buffering the evp.MapPoint (the location clicked by the user) so that it used a larger area.

Steve
0 Kudos
StephenLead
Regular Contributor III
Does this imply that a separate query/query execution/info window would need to be created for each separate layer? Are there best practices/methods of achieving this?


I'd be curious to see the a recommendation on best practices, too.
0 Kudos
derekswingley1
Frequent Contributor
... when I query a point or polyline (and alter the /MapServer/# and the outFields accordingly), my query returns 0 results (it is a valid query). I'm wondering if it has something to do with the spatial relationship? I've attempted to max out the maxAllowableOffset, but that doesn't seem to alter anything. Does anyone have any ideas on this?


maxAllowableOffset isn't used to buffer your query point; it's actually used to generalize the features returned from the server. If you're querying points, it doesn't do anything. I wrote a blog post about this a while back:  Generalize features on the fly. Also see Determining limits for map graphics for more info on maxAllowableOffset.

Unfortunately, query doesn't have a tolerance like the identify task parameters but you can build it yourself. Do something like this:
var pixelWidth = map.extent.getWidth() / map.width,
    queryTolerance = pixelWidth * 3,
    queryGeom = new esri.geometry.Extent({
        'xmin': evt.mapPoint.x - queryTolerance,
        'ymin': evt.mapPoint.y - queryTolerance,
        'xmax': evt.mapPoint.x + queryTolerance,
        'ymax': evt.mapPoint.y + queryTolerance
    });
queryFilter.geometry = queryGeom;

Basically, use the width of a pixel * 3 as your tolerance, use that to build an extent which is then used in your query instead of a point.
0 Kudos
DuncanRager
New Contributor
Thanks to both of you, very helpful and successful. I also understand the concept of maxAllowableOffset now... I was scratching my head before when the graphics highlighting my polygons were simple triangles...

DR
0 Kudos