async void mapView1_Loaded(object sender, RoutedEventArgs e) { //iterate over all layers var taskResults = new List<Task<AllLayersServiceInfo>>(); foreach (var layer in mapView1.Map.Layers) { if (layer is ArcGISDynamicMapServiceLayer) taskResults.Add((layer as ArcGISDynamicMapServiceLayer).GetAllDetailsAsync()); else if (layer is ArcGISTiledMapServiceLayer) taskResults.Add((layer as ArcGISTiledMapServiceLayer).GetAllDetailsAsync()); } var allLayers = await Task.WhenAll(taskResults); //show single node for tiledLayers //show sub-layer list for Dynamic Layers dynamicServiceLayer = mapView1.Map.Layers["DynamicLayerCalifornia"] as ArcGISDynamicMapServiceLayer; if (dynamicServiceLayer != null) { await dynamicServiceLayer.InitializeAsync(); var dyn = dynamicServiceLayer.CreateDynamicLayerInfosFromLayerInfos(); dynamicServiceLayer.VisibleLayers = GetDefaultVisibleLayers(dyn); DataContext = this; Layers = new ObservableCollection<DynamicLayerInfo>(dyn); var test = Layers.Select(x => new { Name = x.Name, Visibility = x.DefaultVisibility, Id = x.ID }).ToList(); } }
async void mapView1_Loaded(object sender, RoutedEventArgs e) { //iterate over all layers var taskResults = new List <Task <AllLayersServiceInfo> >(); foreach (var layer in mapView1.Map.Layers) { if (layer is ArcGISDynamicMapServiceLayer) { taskResults.Add((layer as ArcGISDynamicMapServiceLayer).GetAllDetailsAsync()); } else if (layer is ArcGISTiledMapServiceLayer) { taskResults.Add((layer as ArcGISTiledMapServiceLayer).GetAllDetailsAsync()); } } var allLayers = await Task.WhenAll(taskResults); //show single node for tiledLayers //show sub-layer list for Dynamic Layers dynamicServiceLayer = mapView1.Map.Layers["DynamicLayerCalifornia"] as ArcGISDynamicMapServiceLayer; if (dynamicServiceLayer != null) { await dynamicServiceLayer.InitializeAsync(); var dyn = dynamicServiceLayer.CreateDynamicLayerInfosFromLayerInfos(); dynamicServiceLayer.VisibleLayers = GetDefaultVisibleLayers(dyn); DataContext = this; Layers = new ObservableCollection <DynamicLayerInfo>(dyn); var test = Layers.Select(x => new { Name = x.Name, Visibility = x.DefaultVisibility, Id = x.ID }).ToList(); } }
private void mapView_LayerLoaded(object sender, LayerLoadedEventArgs e) { if (e.LoadError != null) { MessageBox.Show(e.LoadError.Message, "Layer Error"); return; } if (e.Layer == _usaLayer) { if (_usaLayer.DynamicLayerInfos == null) { _usaLayer.DynamicLayerInfos = _usaLayer.CreateDynamicLayerInfosFromLayerInfos(); } _usaLayer.VisibleLayers = new ObservableCollection <int>(_usaLayer.DynamicLayerInfos .Where(info => info.DefaultVisibility == true) .Select((info, idx) => idx)); visibleLayers.ItemsSource = _usaLayer.DynamicLayerInfos .Select((info, idx) => new Tuple <string, int, bool>(info.Name, idx, info.DefaultVisibility)); } }
private void Button_Click(object sender, RoutedEventArgs e) { layer = (map.Layers[0] as ArcGISDynamicMapServiceLayer); DynamicLayerInfoCollection myDynamicLayerInfos = layer.DynamicLayerInfos; if (myDynamicLayerInfos == null) { myDynamicLayerInfos = layer.CreateDynamicLayerInfosFromLayerInfos(); } #region TableDataSource DynamicLayerInfo info = new DynamicLayerInfo() { ID = 1, Source = new LayerDataSource() { DataSource = new QueryDataSource() { GeometryType = ESRI.ArcGIS.Client.Tasks.GeometryType.Polyline, OIDFields = new string[] { "OBJECTID" }, Query = "SELECT * FROM SDE.china_road where FNODE_ > 1000", WorkspaceID = "MyDatabaseWorkspaceID" } } }; #endregion #region QueryDataSource DynamicLayerInfo info = new DynamicLayerInfo() { ID = 1, Source = new LayerDataSource() { DataSource = new QueryDataSource() { GeometryType = ESRI.ArcGIS.Client.Tasks.GeometryType.Polyline, OIDFields = new string[] { "OBJECTID" }, Query = "SELECT * FROM SDE.china_road where FNODE_ > 1000", WorkspaceID = "MyDatabaseWorkspaceID" } } }; #endregion #region UserDefine Simple Render Line //LayerDrawingOptions layerDrawOptions = new LayerDrawingOptions(); //layerDrawOptions.LayerID = 1; //layerDrawOptions.Renderer = new SimpleRenderer() //{ // Symbol = new SimpleLineSymbol() // { // Color = new SolidColorBrush(Color.FromArgb((int)255, (int)0, (int)0, (int)255)), // Width = 2 // } //}; //layer.LayerDrawingOptions = new LayerDrawingOptionsCollection() { layerDrawOptions }; #endregion #region UserDefine Simple Render Poly LayerDrawingOptions layerDrawOptions = new LayerDrawingOptions(); layerDrawOptions.LayerID = 1; layerDrawOptions.Renderer = new SimpleRenderer() { Symbol = new SimpleFillSymbol() { Fill = new SolidColorBrush(Color.FromArgb((int)255, (int)0, (int)0, (int)255)), } }; layer.LayerDrawingOptions = new LayerDrawingOptionsCollection() { layerDrawOptions }; #endregion #region JoinDataSource DynamicLayerInfo info = new DynamicLayerInfo() { ID = 1, Source = new LayerDataSource() { DataSource = new JoinDataSource() { JoinType = JoinType.LeftInnerJoin, LeftTableSource = new LayerDataSource() { DataSource = new TableDataSource() { DataSourceName = "SDE.china_county", WorkspaceID = "MyDatabaseWorkspaceID" } }, LeftTableKey = "OBJECTID", RightTableSource = new LayerDataSource() { DataSource = new TableDataSource() { DataSourceName = "SDE.china_road", WorkspaceID = "MyDatabaseWorkspaceID" } }, RightTableKey = "OBJECTID" } } }; #endregion #region RasterDataSource //DynamicLayerInfo info = new DynamicLayerInfo() //{ // ID = 1, // Source = new LayerDataSource() // { // DataSource = new RasterDataSource() // { // DataSourceName = "rr1", // WorkspaceID = "MyRasterWorkspaceID" // } // } //}; #endregion myDynamicLayerInfos.Add(info); layer.DynamicLayerInfos = myDynamicLayerInfos; layer.VisibleLayers = new int[] { 1 }; //layer.Refresh(); //map.ZoomTo(new Envelope(11.8435360079, 49.4443060783, 11.8568721432, 49.4528247773)); //map.ZoomTo(layer.Layers[1].e) #region Generate Render Class Break ClassBreaksDefinition classBreaksDefinition = new ClassBreaksDefinition() { ClassificationField = "FNODE_", ClassificationMethod = ClassificationMethod.StandardDeviation, BreakCount = 10, StandardDeviationInterval = ESRI.ArcGIS.Client.Tasks.StandardDeviationInterval.OneQuarter }; classBreaksDefinition.ColorRamps.Add(new ColorRamp() { From = Colors.Blue, To = Colors.Red, Algorithm = Algorithm.HSVAlgorithm }); GenerateRendererParameters rendererParams = new GenerateRendererParameters() { ClassificationDefinition = classBreaksDefinition, Source = info.Source }; generateRendererTask.ExecuteAsync(rendererParams, rendererParams.Where); #endregion #region Generate Render Unique Value UniqueValueDefinition uniqueValueDefinition = new UniqueValueDefinition() { Fields = new List<string>() { "FNODE_" } }; uniqueValueDefinition.ColorRamps.Add(new ColorRamp() { From = Colors.Blue, To = Colors.Red, Algorithm = Algorithm.CIELabAlgorithm }); GenerateRendererParameters rendererParams = new GenerateRendererParameters() { ClassificationDefinition = uniqueValueDefinition, Source = info.Source }; generateRendererTask.ExecuteAsync(rendererParams, rendererParams.Where); #endregion }
private void Button_Click(object sender, RoutedEventArgs e) { layer = (map.Layers[0] as ArcGISDynamicMapServiceLayer); DynamicLayerInfoCollection myDynamicLayerInfos = layer.DynamicLayerInfos; if (myDynamicLayerInfos == null) { myDynamicLayerInfos = layer.CreateDynamicLayerInfosFromLayerInfos(); } #region TableDataSource DynamicLayerInfo info = new DynamicLayerInfo() { ID = 1, Source = new LayerDataSource() { DataSource = new QueryDataSource() { GeometryType = ESRI.ArcGIS.Client.Tasks.GeometryType.Polyline, OIDFields = new string[] { "OBJECTID" }, Query = "SELECT * FROM SDE.china_road where FNODE_ > 1000", WorkspaceID = "MyDatabaseWorkspaceID" } } }; #endregion #region QueryDataSource DynamicLayerInfo info = new DynamicLayerInfo() { ID = 1, Source = new LayerDataSource() { DataSource = new QueryDataSource() { GeometryType = ESRI.ArcGIS.Client.Tasks.GeometryType.Polyline, OIDFields = new string[] { "OBJECTID" }, Query = "SELECT * FROM SDE.china_road where FNODE_ > 1000", WorkspaceID = "MyDatabaseWorkspaceID" } } }; #endregion #region UserDefine Simple Render Line //LayerDrawingOptions layerDrawOptions = new LayerDrawingOptions(); //layerDrawOptions.LayerID = 1; //layerDrawOptions.Renderer = new SimpleRenderer() //{ // Symbol = new SimpleLineSymbol() // { // Color = new SolidColorBrush(Color.FromArgb((int)255, (int)0, (int)0, (int)255)), // Width = 2 // } //}; //layer.LayerDrawingOptions = new LayerDrawingOptionsCollection() { layerDrawOptions }; #endregion #region UserDefine Simple Render Poly LayerDrawingOptions layerDrawOptions = new LayerDrawingOptions(); layerDrawOptions.LayerID = 1; layerDrawOptions.Renderer = new SimpleRenderer() { Symbol = new SimpleFillSymbol() { Fill = new SolidColorBrush(Color.FromArgb((int)255, (int)0, (int)0, (int)255)), } }; layer.LayerDrawingOptions = new LayerDrawingOptionsCollection() { layerDrawOptions }; #endregion #region JoinDataSource DynamicLayerInfo info = new DynamicLayerInfo() { ID = 1, Source = new LayerDataSource() { DataSource = new JoinDataSource() { JoinType = JoinType.LeftInnerJoin, LeftTableSource = new LayerDataSource() { DataSource = new TableDataSource() { DataSourceName = "SDE.china_county", WorkspaceID = "MyDatabaseWorkspaceID" } }, LeftTableKey = "OBJECTID", RightTableSource = new LayerDataSource() { DataSource = new TableDataSource() { DataSourceName = "SDE.china_road", WorkspaceID = "MyDatabaseWorkspaceID" } }, RightTableKey = "OBJECTID" } } }; #endregion #region RasterDataSource //DynamicLayerInfo info = new DynamicLayerInfo() //{ // ID = 1, // Source = new LayerDataSource() // { // DataSource = new RasterDataSource() // { // DataSourceName = "rr1", // WorkspaceID = "MyRasterWorkspaceID" // } // } //}; #endregion myDynamicLayerInfos.Add(info); layer.DynamicLayerInfos = myDynamicLayerInfos; layer.VisibleLayers = new int[] { 1 }; //layer.Refresh(); //map.ZoomTo(new Envelope(11.8435360079, 49.4443060783, 11.8568721432, 49.4528247773)); //map.ZoomTo(layer.Layers[1].e) #region Generate Render Class Break ClassBreaksDefinition classBreaksDefinition = new ClassBreaksDefinition() { ClassificationField = "FNODE_", ClassificationMethod = ClassificationMethod.StandardDeviation, BreakCount = 10, StandardDeviationInterval = ESRI.ArcGIS.Client.Tasks.StandardDeviationInterval.OneQuarter }; classBreaksDefinition.ColorRamps.Add(new ColorRamp() { From = Colors.Blue, To = Colors.Red, Algorithm = Algorithm.HSVAlgorithm }); GenerateRendererParameters rendererParams = new GenerateRendererParameters() { ClassificationDefinition = classBreaksDefinition, Source = info.Source }; generateRendererTask.ExecuteAsync(rendererParams, rendererParams.Where); #endregion #region Generate Render Unique Value UniqueValueDefinition uniqueValueDefinition = new UniqueValueDefinition() { Fields = new List <string>() { "FNODE_" } }; uniqueValueDefinition.ColorRamps.Add(new ColorRamp() { From = Colors.Blue, To = Colors.Red, Algorithm = Algorithm.CIELabAlgorithm }); GenerateRendererParameters rendererParams = new GenerateRendererParameters() { ClassificationDefinition = uniqueValueDefinition, Source = info.Source }; generateRendererTask.ExecuteAsync(rendererParams, rendererParams.Where); #endregion }