ArcGIS API for Silverlight – Advanced Topics July 25-26, 2012 ArcGIS API for Silverlight – Advanced Topics Rex Hansen Jennifer Nery
Agenda Introductions and overview Graphics data sources ArcGIS Portal API High-Quality Printing Deep dive into image services Editing workflow Dynamic Layers with Query Statistics
Graphics Data Sources Jennifer Nery
Adding Graphics to GraphicsLayer foreach(Graphic g in myGraphics) graphicsLayer.Graphics.Add(myGraphics); or graphicsLayer.GraphicsSource = myGraphics; read-only when GraphicsSource is used! can by any IEnumerable<Graphic>
Adding Custom Data to a GraphicsLayer public class MyData { public double Longitude { get; set; } public double Latitude { get; set; } } … foreach(MyData in dataList) myGraphicsLayer.Graphics.Add( new Graphic() { new MapPoint(Longitude, Latitude) );
…Simpler with PointDataSource <esri:GraphicsLayer> <esri:GraphicsLayer.GraphicsSource> <esri:PointDataSource XCoordinateBinding="{Binding Longitude}" YCoordinateBinding="{Binding Latitude}" ItemsSource="{StaticResource dataList}" /> </esri:GraphicsLayer.GraphicsSource> </esri:GraphicsLayer>
ArcGIS Portal API Jennifer Nery
using ESRI.ArcGIS.Client.Portal var portal = new ArcGISPortal(“http://serverURL”); var parameters = new SearchParameters { QueryString = query.Text, Limit = 5 }; portal.SearchItemsAsync(parameters, (result, error) => { if(error == null) Results.ItemsSource = result.Results; };
<ListBox x:Name=“Results”> <ListBox <ListBox x:Name=“Results”> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text=“{Binding Title}”/> <TextBlock Text=“{Binding Owner}”/> <Image Source=“{Binding ThumbnailUri}”/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
…with IdentityManager IdentityManager.Current.RegisterServers( new ServerInfo[ ] { new ServerInfo() { ServerURL = “http://serverURL”, TokenServiceURL = “http://tokenURL” } }); IdentityManager.Current.ChallengeMethod = Challenge;
Sign in IdentityManager.Current.GenerateCredentialAsync( “http://serverURL”, username, password, (credential, error) => { if(error == null) { IdentityManager.AddCredential(credential); Portal.InitializeAsync(“http://serverURL”, (crd, ex) => {…} ) ; } } );
Sign out var credential = IdentityManager.Current.FindCredential( “http://serverURL”, username); IdentityManager.Current.RemoveCredential(credential ); portal.InitializeAsync(“http://serverURL”, (crd, ex) => {…});
High-Quality Printing Jennifer Nery
using ESRI.ArcGIS.Client.Printing var printTask = new PrintTask(“http://taskUrl”); printTask.ExecuteCompleted += (s, e) => { if (e.Error == null) HtmlPage.Window.Navigate(e.PrintResult.Url, “_blank”); }; printTask.ExecuteAsync(new PrintParameters(MyMap)); or printTask.StatusUpdated += (s, e) => {…}; printTask.JobCompleted += (s, e) => {…}; printTask.SubmitJob(…);
<StackPanel x:Name=“PrintPanel”> <ComboBox x:Name=“Templates” ItemsSource=“{Binding LayoutTemplates}”/> <ComboBox x:Name=“Formats” ItemsSource=“{Binding Formats}”/> <TextBox x:Name=“MapTitle” Text=“Print Demo”/> </StackPanel> printTask.GetServiceInfoCompleted += (s, e) => { PrintPanel.DataContext = e.ServiceInfo; }; printTask.GetServiceInfoAsync();
var printParams= new PrintParameters(MyMap); printParams var printParams= new PrintParameters(MyMap); printParams.LayoutTemplate = (string) Templates.SelectedItem; printParams.Format = (string) Formats.SelectedItem; printParams.LayoutOptions = new LayoutOptions() { Title = MapTitle.Text, LegendOptions = new LegendOptions() {…}, ScaleBarOptions = new ScaleBarOptions() {…}, … }; printParams.MapOptions = new MapOptions() {…}; printParams.ExportOptions = new ExportOptions() {…} printTask.ExecuteAsync(printParams);
PrintTask: Known Limitations in v3.0 Custom symbols/renderers Clustering KmlLayer does not support visibleFolders GraphicsLayer with mixed geometries FeatureLayer selection/geometry require ObjectID
Related Session Supporting High-Quality Printing in Web Applications with ArcGIS 10.1 Server Thursday, July 26, 2012 8:30 AM – 9:45 AM Room 07 A/B
Diving into Image Services Rex Hansen
Image Server Editing Add, update and delete rasters in a mosaic dataset public class ArcGISImageServiceLayer : Layer { AddRasters( ImageServiceAddParameters, Action<ImageServiceEditResults, Exception>) UpdateRaster( ImageServiceUpdateParameters, Action<ImageServiceEditResults, Exception>) DeleteRasters( IEnumerable<int>, Action<ImageServiceEditResults, Exception>) }
Upload Task Great for upload of large files Provides progress, cancellation and deletion Great for large geoprocessing input or raster uploads
Mensuration Task New task for measuring length, height, area etc. based on imagery data public class MensurationTask : TaskBase { Point ( … ) DistanceAndAngle ( … ) HeightFromBaseToTop ( … ) HeightFromBaseAndTopShadow ( … ) HeightFromTopAndTopShadow ( … ) AreaAndPerimeter ( … ) Centroid ( … ) }
Raster Functions Common and custom functions to change how a raster is rendered RasterFuctionsComboBox.ItemsSource = imgLayer.RasterFunctionInfos; var rasterFunction = RasterFuctionsComboBox.SelectedItem as RasterFunctionInfo; RenderingRule renderingRule = new RenderingRule() { RasterFunctionName = rasterFunction.Name }; imgLayer.RenderingRule = renderingRule; imgLayer.Refresh();
Editing Workflow Rex Hansen
Editor Tracking Feature last edited by another user Feature moved, last edited user and date updated
Ownership Can’t update or delete, don’t own the feature Created feature, can update and delete
Attribute-only editing Feature is not allowed for delete or geometry edit.
Feature Service – Editor Tracking FeatureLayer.EditUserName Client side validation FeatureLayer.IsUpdateAllowed(graphic) Check if feature can be updated FeatureLayer.IsGeometryUpdateAllowed(graphic) Check if feature’s geometry can be updated FeatureLayerInfo.EditFieldsInfo Owner, editor, date FeatureLayerInfo.OwnershipBasedAccessControl If others can update, delete FeatureLayerInfo.AllowGeometryUpdates Attribute only editing
Dynamic Layers with Query Statistics Rex Hansen
Change the renderers LayerDrawingOptions: Allows you to override the renderer for each layer. Use GenerateRendererTask helper to create good class breaks. DynamicLayerInfos: Reorder the layers Change the source data Map layers, workspaces, tables, joins…
DynamicLayerInfos LayerMapSource LayerDataSource: reference layers already in map service LayerDataSource: TableDataSource (workspaces & GDB versions) QueryDataSource (query layers) RasterDataSource (raster data) JoinDataSource (join the above sources) Note: When you use DynamicLayerInfos, you replace all existing layer infos.
QueryTask - Statistics Sum, Average, Min, Max, Count, Standard Deviation, Variance var query = new Query() { GroupByFieldsForStatistics = new List<string> { "SUB_REGION" }, OutStatistics = new List<OutStatistic> { new OutStatistic() { OnStatisticField = "POP2000", OutStatisticFieldName = "SubRegionPopulation", StatisticType = StatisticType.Sum . . .
Thank you for attending Have fun at UC2012 Open for Questions Please fill out the evaluation: www.esri.com/ucsessionsurveys First Offering ID: 787 Second Offering ID: 1936