MyMap.Extent = arcGisLocalDynamicMapServiceLayer.FullExtent;
// Create a new FeatureLayer instance passing in the local service. FeatureLayer featureLayer = new FeatureLayer() { // Construct the URL to include the /dynamicLayer resource. Url = localMapService.UrlMapService + "/dynamicLayer", // Assign ID ID = fileName, // Display all fields OutFields = new ESRI.ArcGIS.Client.Tasks.OutFields() { "*" }, // Yellow is generally a nice selection color SelectionColor = new SolidColorBrush(Colors.Yellow), }; // The workspace is a feature class so create a new TableDataSource DataSource dataSource = new TableDataSource { // Match the DataSourceName to the physical filename on disk (excluding extension). DataSourceName = fileName, // Provide the WorkspaceID (the unique workspace identifier created earlier). WorkspaceID = workspaceInfo.Id }; // Set the Source property of the DynamicLayerInfo object. LayerDataSource layerDataSource = new LayerDataSource { DataSource = dataSource }; // Assign the LayerDataSource featureLayer.Source = layerDataSource;
// 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 + "'" + "}}}"));
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.