/* * Apply a renderer for vector layers. * Note: It is always necessary to provide a renderer when the layer being added (represented by a DynamicLayerInfo) is part of a new * DynamicLayerInfoCollection as opposed to using the CreateDynamicLayerInfosFromLayerInfos() method which creates a DynamicLayerInfoCollection * containing the existing layers in the map service. */ // Create a new LayerDrawingOptions object to hold the renderer information. var layerDrawOpt = new LayerDrawingOptions() { // Match up the LayerID to the ID of the layer within the service. LayerID = counter, }; // We need to determine the geometry type of the new feature class. // To do this, we will submit a request to the ..\MapServer\dynamicLayer?.. endpoint which will return the service level metadata, // Allowing us to identify the geometry type and create an appropriate renderer. // Create a new WebClient instance to make the request and download the response. WebClient webClient = new WebClient(); // Register an asynchronous handler in which to create the renderers and apply the to the dynamic map service layer. webClient.DownloadDataCompleted += (client, downloadDataEventArgs) => { // Read the JSON response as XML XmlReader reader = System.Runtime.Serialization.Json.JsonReaderWriterFactory.CreateJsonReader(downloadDataEventArgs.Result, new XmlDictionaryReaderQuotas()); // Get the root XML element XElement root = XElement.Load(reader); // Query for the "geometryType" element XElement geometryType = root.XPathSelectElement("//geometryType"); // Create the render based on the geometry type switch (geometryType.Value) { case "esriGeometryPoint": layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(GetRandomColor()), Size=8 } }; break; case "esriGeometryPolyline": layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = new SimpleLineSymbol() { Color = new SolidColorBrush(GetRandomColor()) } }; break; case "esriGeometryPolygon": layerDrawOpt.Renderer = new SimpleRenderer() { Symbol = new SimpleFillSymbol() { Fill = new SolidColorBrush(GetRandomColor()), BorderBrush = new SolidColorBrush(GetRandomColor()) } }; break; } // Set the LayerDrawingOptions property on the local dynamic map service layer (the LayerID property ties this to the DynamicLayerInfo object). layerDrawingOptionsCollection.Add(layerDrawOpt); // Update the layer drawing options property on the dynamic map service layer. arcGisLocalDynamicMapServiceLayer.LayerDrawingOptions = layerDrawingOptionsCollection; // Need to refresh the layer after the renderer(s) have been applied. arcGisLocalDynamicMapServiceLayer.Refresh(); }; // Make the request for the service metadata // e.g. http://127.0.0.1:<PORT>/arcgis/rest/services/<MPK_NAME>/MapServer/dynamicLayer?layer={"id":0,"source":{"type":"dataLayer","dataSource":{"type":"table","workspaceId":"MyWorkspace","dataSourceName":"MyFeatureClassName"}}} webClient.DownloadDataAsync(new Uri(arcGisLocalDynamicMapServiceLayer.Url + "/dynamicLayer?layer={'id':" + counter.ToString() + "," + "'source':{'type':'dataLayer','dataSource':{" + "'type':'table'," + "'workspaceId':'"+ workspaceInfo.Id + "'," + "'dataSourceName':'" + fileName + "'" + "}}}"));
Hi,You've actually got several options here... #1. QueryTask:- Probably the best option... set the search geometry via the Query Class (http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Tasks.Query_members.html).#2. GeometryService task:- The GeometryService is typically very quick/efficient but this route would require first retrieving the polygon geometries to submit as graphics which may incur an overhead (you'd need to submit a query first). Take a look at the Relation operation:API ref: http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Tasks.GeometryService~Relation.htmlSample: http://resources.arcgis.com/en/help/runtime-wpf/samples/index.html#/Relation/02q200000056000000/#3. Geoprocessor task:- This would require creating a model/script and packaging as a GPK but you could craft the GP tool to give you the exact response you want (e.g. just a boolean yes/no).CheersMike
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.