Select to view content in your preferred language

New Samples Released - Query Related Records & Go To Coordinates

3873
7
08-30-2012 05:26 PM
KatherineDalton
Esri Regular Contributor
We're pleased to announce the release of the Query Related Records & Go To Coordinates samples for the ArcGIS Viewer for Silverlight. These samples work with the current release (v1.0.1) and are built on the ArcGIS API for Silverlight v2.4.

Query Related Records
The Query Related Records tool demonstrates how to query for the related records of a feature by using the feature's pop-up information. Clicking the tool on the pop-up toolbar executes the query and the results are displayed in the Viewer's attribute table. This tool is intended as a sample upon which you can refine and customize as appropriate. For example, the tool specifies that all fields are returned from the QueryTask, but it may be more appropriate for you to limit the fields to be returned. The tool also queries the first relationship it finds, and thus you may want to change that value, or extend the tool to display a dialog allowing the end user to choose the desired relationship.

Go To Coordinates
Go To Coordinates is a ready-to-deploy sample that takes in a latitude and longitude coordinate value and goes to the specified location. The tool's dialog box also displays the current map extent. The tool is designed to work with Web Mercator and WGS84. As with the Query Related Records tool, we recommend using it as a sample and building on top of it to create the look, feel, and functionality you need.

Please see the Description and Deployment Instructions included in each sample for additional information.

~The ArcGIS Viewer for Silverlight team
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
7 Replies
ValentinFedulov
Occasional Contributor

The Query Related Records tool demonstrates how to query for the related records of a feature by using the feature's pop-up information.


Query Related Records tool, fixed and extended

Extensions:
1. You can view related data for ArcGISDynamicMapServiceLayer sublayers, not only for FeatureLayer.
2. You can select relation from list if there is more than one relation.
0 Kudos
KarenEllett
Regular Contributor
When I test this on a deployed application, it shows the tool icon for all popups, even on features without related records.  When I click the icon it sticks on the busy indicator and never does anything.  When I test it within the builder, it gives me the following error:
Object reference not set to an instance of an object.
at QueryRelatedRecords.AddIns.QueryRelatedTool.resultsLayer_Initialized(Object sender, EventArgs e)
   at ESRI.ArcGIS.Client.Layer.OnInitialized(EventArgs e)
   at ESRI.ArcGIS.Client.Layer.Initialize()
   at ESRI.ArcGIS.Client.FeatureLayer.info_Error(Object sender, TaskFailedEventArgs e)
   at ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo.OnError(Exception err)
   at ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo.Execute_Completed(Object sender, DownloadStringCompletedEventArgs e)
   at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)
   at System.Net.WebClient.DownloadStringOperationCompleted(Object arg)
0 Kudos
KarenEllett
Regular Contributor
Looking at it further, I think I've found the root of the problem, but have no idea how to approach it.

It appears the problem starts when it tries to create the results layer.  In Fiddler when it sends off to the rest to do the query of related records, it correctly sends to the Host gisadv02.  However, the next two lines show it trying to access clientaccesspolicy.xml and crossdomain.xml, and both cause problems because it is sending to the host gisadv2.  It has stripped out the 0.

Any suggestions on how/where to fix this??
0 Kudos
ValentinFedulov
Occasional Contributor
... In Fiddler when it sends off to the rest to do the query of related records, it correctly sends to the Host gisadv02.  However, the next two lines show it trying to access clientaccesspolicy.xml and crossdomain.xml, and both cause problems because it is sending to the host gisadv2.  It has stripped out the 0.

Any suggestions on how/where to fix this??

It seems like you need add clientaccesspolicy.xml to root of gisadv2 web site
http://help.arcgis.com/en/webapps/silverlightviewer/help/index.html#/Frequently_asked_questions/0177...
0 Kudos
RPW
by
Occasional Contributor
It has stripped out the 0.


I have exactly the same problem, the "0" is removed from the server name.

Thanks for helping,
Roger
0 Kudos
ValentinFedulov
Occasional Contributor
I have exactly the same problem, the "0" is removed from the server name.

Thanks for helping,
Roger


Well, I think I know where bug is.
It's code
        
private void QueryTask_ExecuteRelationshipQueryCompleted(object sender, RelationshipEventArgs e)
        {
            // queryResult used once the results layer is initialized
            queryResult = e.Result;
            // Create a new url for the related table using the querytaskUrl and the RelatedTableId.
            string resultsUrl = relatesLayer.Url;
            string[] splitResultUrl = resultsUrl.Split('/');
            resultsUrl = resultsUrl.Replace(splitResultUrl.Last<string>(), "");
            resultsUrl = resultsUrl.Insert(resultsUrl.Length, relationInfo.tableId.ToString());

in file
QueryRelatedRecords\QueryRelatedRecords.AddIns\QueryRelatedTool.cs

I'l do some tests and post fixed version ASAP.
0 Kudos
ValentinFedulov
Occasional Contributor
I have exactly the same problem, the "0" is removed from the server name.

Thanks for helping,
Roger


bug fixed, updated version
http://www.arcgis.com/home/item.html?id=6cee9dfda5a240939333569c403a4400
0 Kudos