private void AddResultLayer(GraphicsLayer resultsLayer, bool isSelected, string displayName, ESRI.ArcGIS.Mapping.Core.GeometryType geometryType, int?index) { resultsLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty, displayName); resultsLayer.ID = displayName; resultsLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.InitialUpdateCompletedProperty, true); if (index == null || index.Value < 0 || index.Value >= Map.Layers.Count) { Map.Layers.Add(resultsLayer); } else { Map.Layers.Insert(index.Value, resultsLayer); } }
/// <summary> /// Converts a single graphic "note" element into a graphics layer. /// </summary> /// <param name="name">The name to assign to the graphics layer.</param> /// <param name="graphic">The graphic element to add to the graphics layer.</param> /// <param name="map">The map to which the layer will eventually be added, to prevent name conflicts with existing layers.</param> /// <returns>A graphics layer that contains the graphic element.</returns> public static GraphicsLayer CreateGraphicsLayer(string name, Graphic graphic, Map map) { graphic.Attributes["Name"] = name; GraphicsLayer graphicsLayer = new GraphicsLayer(); graphicsLayer.ID = name; if (string.IsNullOrEmpty(graphicsLayer.ID) || (!string.IsNullOrEmpty(graphicsLayer.ID) && map.Layers[graphicsLayer.ID] != null)) { graphicsLayer.ID = Guid.NewGuid().ToString("N"); } graphicsLayer.Graphics.Add(graphic); graphicsLayer.Renderer = new ESRI.ArcGIS.Mapping.Core.Symbols.HiddenRenderer(); graphicsLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty, name); Collection <FieldInfo> fields = new Collection <FieldInfo>(); fields.Add(new FieldInfo() { Name = "Name", VisibleInAttributeDisplay = true, DisplayName = "Name", FieldType = FieldType.Text, VisibleOnMapTip = false }); ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetFields(graphicsLayer, fields); return(graphicsLayer); }
private void initializeBusyLayer() { ESRI.ArcGIS.Client.Symbols.MarkerSymbol busySymbol = new Client.Symbols.MarkerSymbol() { OffsetX = 9, OffsetY = 9 }; busySymbol.ControlTemplate = XamlReader.Load( @"<ControlTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:mapping=""http://schemas.esri.com/arcgis/mapping/2009""> <mapping:ActivityIndicator HorizontalAlignment=""Center"" VerticalAlignment=""Center"" AutoStartProgressAnimation=""True""> <mapping:ActivityIndicator.Effect> <DropShadowEffect ShadowDepth=""0"" BlurRadius=""5"" Color=""White"" /> </mapping:ActivityIndicator.Effect> </mapping:ActivityIndicator> </ControlTemplate>") as ControlTemplate; Graphic busyGraphic = new Graphic() { Geometry = clickPoint, Symbol = busySymbol }; busyLayer = new GraphicsLayer() { RendererTakesPrecedence = false }; busyLayer.SetValue(ESRI.ArcGIS.Mapping.Core.LayerExtensions.ExcludeSerializationProperty, true); busyLayer.Graphics.Add(busyGraphic); }
public static void SetGeometryType(GraphicsLayer graphicsLayer, GeometryType value) { if (graphicsLayer == null) { throw new ArgumentNullException("graphicsLayer"); } graphicsLayer.SetValue(GeometryTypeProperty, value); }
/// <summary> /// Converts a single graphic "note" element into a graphics layer. /// </summary> /// <param name="name">The name to assign to the graphics layer.</param> /// <param name="graphic">The graphic element to add to the graphics layer.</param> /// <param name="map">The map to which the layer will eventually be added, to prevent name conflicts with existing layers.</param> /// <returns>A graphics layer that contains the graphic element.</returns> public static GraphicsLayer CreateGraphicsLayer(string name, Graphic graphic, Map map) { graphic.Attributes["Name"] = name; GraphicsLayer graphicsLayer = new GraphicsLayer(); graphicsLayer.ID = name; if (string.IsNullOrEmpty(graphicsLayer.ID) || (!string.IsNullOrEmpty(graphicsLayer.ID) && map.Layers[graphicsLayer.ID] != null)) graphicsLayer.ID = Guid.NewGuid().ToString("N"); graphicsLayer.Graphics.Add(graphic); graphicsLayer.Renderer = new ESRI.ArcGIS.Mapping.Core.Symbols.HiddenRenderer(); graphicsLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty, name); Collection<FieldInfo> fields = new Collection<FieldInfo>(); fields.Add(new FieldInfo() { Name = "Name", VisibleInAttributeDisplay = true, DisplayName = "Name", FieldType = FieldType.Text, VisibleOnMapTip = false }); ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetFields(graphicsLayer, fields); return graphicsLayer; }
private void PerformPostLayerInitializationActions(Layer layer, bool initializationSuccess) { GraphicsLayer gLayer = layer as GraphicsLayer; if (gLayer != null) { GeometryType geometryType = Core.LayerExtensions.GetGeometryType(gLayer); Collection <FieldInfo> layerFields = Core.LayerExtensions.GetFields(gLayer); FeatureLayer featureLayer = layer as FeatureLayer; if (layerFields.Count == 0 && featureLayer != null && featureLayer.LayerInfo != null && featureLayer.LayerInfo.Fields != null) { foreach (ESRI.ArcGIS.Client.Field field in featureLayer.LayerInfo.Fields) { if (FieldHelper.IsFieldFilteredOut(field.Type)) { continue; } ESRI.ArcGIS.Mapping.Core.FieldInfo fieldInfo = ESRI.ArcGIS.Mapping.Core.FieldInfo.FieldInfoFromField(featureLayer, field); layerFields.Add(fieldInfo); } } if (gLayer.Graphics != null) { #region Get geometry type, start getting symbology if (geometryType == GeometryType.Unknown && gLayer.Graphics.Count > 0) { geometryType = LayerUtils.GetGeometryTypeFromGraphic(gLayer.Graphics.ElementAtOrDefault(0)); Core.LayerExtensions.SetGeometryType(gLayer, geometryType); if ((gLayer.Renderer == null || gLayer.Renderer is HiddenRenderer) && !Symbology.DefaultSymbols.ContainsKey(geometryType)) { if (geometryType == GeometryType.Unknown) { gLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.ErrorMessageProperty, "Layer has unspecified geometry type."); } else { Core.LayerExtensions.SetRunLayerPostInitializationActions(gLayer, true); SymbolConfigProvider.GetDefaultLinearGradientBrush(gLayer, ColorRampType.ClassBreaks); } return; } } #endregion #region Project graphics if necessary if (graphicsRequireReprojection(gLayer.Graphics)) { GeometryServiceOperationHelper helper = new GeometryServiceOperationHelper( new ConfigurationStoreHelper().GetGeometryServiceUrl(ConfigurationStore) ); helper.ProjectGraphicsCompleted += (sender, args) => { GraphicsLayer targetLayer = args.UserState as GraphicsLayer; if (targetLayer != null) { targetLayer.Graphics.Clear(); foreach (Graphic graphic in args.Graphics) { targetLayer.Graphics.Add(graphic); } } }; helper.ProjectGraphics(gLayer.Graphics, Map.SpatialReference, gLayer); } #endregion #region Get field information if (layerFields.Count == 0) // fields not determined yet { determineFieldsFromGraphic(layerFields, gLayer.Graphics.ElementAtOrDefault(0)); } #endregion } #region Get renderer from feature layer's layer info, if necessary if (gLayer.Renderer == null || gLayer.Renderer is HiddenRenderer) { FeatureLayer lay = gLayer as FeatureLayer; if (lay != null && lay.LayerInfo != null && lay.LayerInfo.Renderer != null) { lay.Renderer = lay.LayerInfo.Renderer; } } #endregion #region Change PictureMarkerSymbol to ImageFillSymbol if (gLayer.Renderer != null && (geometryType == GeometryType.Point || geometryType == GeometryType.MultiPoint)) { SimpleRenderer sr = gLayer.Renderer as SimpleRenderer; ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol pms = null; if (sr != null) { pms = sr.Symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol; if (pms != null) { sr.Symbol = SymbolJsonHelper.ToImageFillSymbol(pms); } } else { ClassBreaksRenderer cbr = gLayer.Renderer as ClassBreaksRenderer; if (cbr != null) { foreach (ClassBreakInfo info in cbr.Classes) { pms = info.Symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol; if (pms != null) { info.Symbol = SymbolJsonHelper.ToImageFillSymbol(pms); } } } else { UniqueValueRenderer uvr = gLayer.Renderer as UniqueValueRenderer; if (uvr != null) { foreach (UniqueValueInfo info in uvr.Infos) { pms = info.Symbol as ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol; if (pms != null) { info.Symbol = SymbolJsonHelper.ToImageFillSymbol(pms); } } } } } } #endregion if (gLayer.Renderer == null || gLayer.Renderer is HiddenRenderer) { ApplyDefaultRenderer(gLayer, geometryType); } ApplyDefaultGradientBrush(gLayer); } else if ((layer is ArcGISDynamicMapServiceLayer || layer is ArcGISTiledMapServiceLayer) && !((bool)layer.GetValue(ESRI.ArcGIS.Client.WebMap.Document.IsBaseMapProperty))) { //get layer infos - used later for figuring out domain/subtypes, etc if ((layer.GetValue(ESRI.ArcGIS.Mapping.Core.LayerExtensions.LayerInfosProperty) as Collection <LayerInformation>) == null) { getLayerInfos(layer); } } bool doSelect = false; layer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.InitialUpdateCompletedProperty, true); if (!initializationSuccess) { layer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.InitialUpdateFailedProperty, true); } else { bool hasId = !string.IsNullOrEmpty(layer.ID) || !string.IsNullOrEmpty(layer.GetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty) as string); // Certain layers get added when the map draw mode is changed (An empty graphics layer is added) // We don't want to auto-select this layer if (hasId || !(layer is GraphicsLayer)) { doSelect = true; } } if (doSelect) { SetSelectedLayer(new LayerEventArgs() { Layer = layer }); } SubscribeToLayerInitializationEvents(layer, false); }
void addInput(ESRI.ArcGIS.Client.Geometry.Geometry geometry) { GraphicsLayer layer = getLayer(); #region Create layer if not already there and add to map if (layer == null) { InputLayerID = Guid.NewGuid().ToString("N"); layer = new GraphicsLayer(); if (config.Layer != null) { layer.Renderer = config.Layer.Renderer; Core.LayerExtensions.SetFields(layer, Core.LayerExtensions.GetFields(config.Layer)); Core.LayerExtensions.SetGeometryType(layer, Core.LayerExtensions.GetGeometryType(config.Layer)); Core.LayerExtensions.SetDisplayField(layer, Core.LayerExtensions.GetDisplayField(config.Layer)); Core.LayerExtensions.SetPopUpsOnClick(layer, Core.LayerExtensions.GetPopUpsOnClick(config.Layer)); LayerProperties.SetIsPopupEnabled(layer, LayerProperties.GetIsPopupEnabled(config.Layer)); } layer.ID = InputLayerID; layer.SetValue(MapApplication.LayerNameProperty, string.IsNullOrEmpty(config.LayerName) ? string.IsNullOrEmpty(config.Label) ? config.Name : config.Label : config.LayerName); layer.Opacity = config.Opacity; Map.Layers.Add(layer); } #endregion #region Add geometry to layer if (config.GeometryType == Core.GeometryType.MultiPoint) // Special handling for MultiPoint geometry { if (layer.Graphics.Count == 0) { // Create a new MultiPoint geometry and add the passed-in point to it var multipoint = new MultiPoint() { SpatialReference = geometry.SpatialReference }; multipoint.Points.Add((MapPoint)geometry); var g = new Graphic() { Geometry = multipoint }; layer.Graphics.Add(g); } else { // Get the sketch graphic's MultiPoint geometry and add the passed-in point to it var multipoint = (MultiPoint)layer.Graphics[0].Geometry; multipoint.Points.Add((MapPoint)geometry); layer.Refresh(); } } else { Graphic g = new Graphic() { Geometry = geometry }; layer.Graphics.Add(g); } #endregion }
void addInput(ESRI.ArcGIS.Client.Geometry.Geometry geometry) { GraphicsLayer layer = getLayer(); #region Create layer if not already there and add to map if (layer == null) { InputLayerID = Guid.NewGuid().ToString("N"); layer = new GraphicsLayer(); if (config.Layer != null) { layer.Renderer = config.Layer.Renderer; Core.LayerExtensions.SetFields(layer, Core.LayerExtensions.GetFields(config.Layer)); Core.LayerExtensions.SetGeometryType(layer, Core.LayerExtensions.GetGeometryType(config.Layer)); Core.LayerExtensions.SetDisplayField(layer, Core.LayerExtensions.GetDisplayField(config.Layer)); Core.LayerExtensions.SetPopUpsOnClick(layer, Core.LayerExtensions.GetPopUpsOnClick(config.Layer)); LayerProperties.SetIsPopupEnabled(layer, LayerProperties.GetIsPopupEnabled(config.Layer)); } layer.ID = InputLayerID; layer.SetValue(MapApplication.LayerNameProperty, string.IsNullOrEmpty(config.LayerName) ? string.IsNullOrEmpty(config.Label) ? config.Name : config.Label : config.LayerName); layer.Opacity = config.Opacity; Map.Layers.Add(layer); } #endregion #region Add geometry to layer Graphic g = new Graphic() { Geometry = geometry }; layer.Graphics.Add(g); #endregion }
public static void SetPopUpsOnClick(GraphicsLayer layer, bool value) { if (layer == null) { throw new ArgumentNullException("layer"); } layer.SetValue(PopUpsOnClickProperty, value); }
/// <summary> /// Sets the value of the Dataset attached property to a specified GraphicsLayer. /// </summary> /// <param name="layer">The GraphicsLayer to which the attached property is written.</param> /// <param name="value">The needed Dataset value.</param> public static void SetDataset(GraphicsLayer layer, string value) { if (layer == null) { throw new ArgumentNullException("element"); } layer.SetValue(DatasetProperty, value); }
public static void SetRunLayerPostInitializationActions(GraphicsLayer layer, bool value) { if (layer == null) { throw new ArgumentNullException("layer"); } if (value) layer.SetValue(RunLayerPostInitializationActionsProperty, value); else layer.ClearValue(RunLayerPostInitializationActionsProperty); }
/// <summary> /// Sets the value of the RendererAttributeDisplayName attached property to a specified GraphicsLayer. /// </summary> /// <param name="element">The GraphicsLayer to which the attached property is written.</param> /// <param name="value">The needed RendererAttributeDisplayName value.</param> public static void SetRendererAttributeDisplayName(GraphicsLayer element, string value) { if (element == null) { throw new ArgumentNullException("element"); } element.SetValue(RendererAttributeDisplayNameProperty, value); }
/// <summary> /// Sets the value of the GradientBrush attached property to a specified GraphicsLayer. /// </summary> /// <param name="graphicsLayer">The GraphicsLayer to which the attached property is written.</param> /// <param name="value">The needed GradientBrush value.</param> public static void SetGradientBrush(GraphicsLayer graphicsLayer, LinearGradientBrush value) { if (graphicsLayer == null) { throw new ArgumentNullException("graphicsLayer"); } graphicsLayer.SetValue(GradientBrushProperty, value); }
public static void SetDisplayField(GraphicsLayer graphicsLayer, string value) { graphicsLayer.SetValue(DisplayFieldProperty, value); SetIsMapTipDirty(graphicsLayer, true); }
public static void SetFields(GraphicsLayer graphicsLayer, Collection<FieldInfo> value) { graphicsLayer.SetValue(FieldsProperty, value); SetIsMapTipDirty(graphicsLayer, true); }
private void AddResultLayer(GraphicsLayer resultsLayer, bool isSelected, string displayName, ESRI.ArcGIS.Mapping.Core.GeometryType geometryType, int? index) { resultsLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.MapApplication.LayerNameProperty, displayName); resultsLayer.ID = displayName; resultsLayer.SetValue(ESRI.ArcGIS.Client.Extensibility.LayerExtensions.InitialUpdateCompletedProperty, true); if (index == null || index.Value < 0 || index.Value >= Map.Layers.Count) Map.Layers.Add(resultsLayer); else Map.Layers.Insert(index.Value, resultsLayer); }
public static void SetIsMapTipDirty(GraphicsLayer graphicsLayer, bool value) { graphicsLayer.SetValue(IsMapTipDirtyProperty, value); }