static public IEnvelope FullExtent(this IServiceMap map) { Envelope fullExtent = null; if (map?.MapElements != null) { foreach (var layer in map.MapElements) { IEnvelope envelope = null; if (layer.Class is IFeatureClass && ((IFeatureClass)layer.Class).Envelope != null) { envelope = ((IFeatureClass)layer.Class).Envelope; } else if (layer.Class is IRasterClass && ((IRasterClass)layer.Class).Polygon != null) { envelope = ((IRasterClass)layer.Class).Polygon.Envelope; } if (envelope != null) { if (fullExtent == null) { fullExtent = new Framework.Geometry.Envelope(envelope); } else { fullExtent.Union(envelope); } } } } return(fullExtent); }
public void InitForm(IServiceMap map) { if (map != null) { if (map.MapElements != null) { Framework.Geometry.Envelope fullExtent = null; foreach (var layer in map.MapElements) { IEnvelope envelope = null; if (layer.Class is IFeatureClass && ((IFeatureClass)layer.Class).Envelope != null) { envelope = ((IFeatureClass)layer.Class).Envelope; } else if (layer.Class is IRasterClass && ((IRasterClass)layer.Class).Polygon != null) { envelope = ((IRasterClass)layer.Class).Polygon.Envelope; } if (envelope != null) { if (fullExtent == null) { fullExtent = new Framework.Geometry.Envelope(envelope); } else { fullExtent.Union(envelope); } } } if (fullExtent != null) { MapExtent = $"{fullExtent.minx.ToDoubleString()},{fullExtent.miny.ToDoubleString()},{fullExtent.maxx.ToDoubleString()},{fullExtent.maxy.ToDoubleString()}"; this.Geometry = $"{ fullExtent.Center.X.ToDoubleString() },{ fullExtent.Center.Y.ToDoubleString() }"; } } ImageDisplay = "800,600,96"; if (map?.Display?.SpatialReference != null) { this.SRef = map.Display.SpatialReference.EpsgCode.ToString(); } this.geometryType = "esriGeometryPoint"; this.PixelTolerance = 1; } }
public void InitForm(IServiceMap map) { if (map != null) { if (map.MapElements != null) { Framework.Geometry.Envelope fullExtent = null; foreach (var layer in map.MapElements) { IEnvelope envelope = null; if (layer.Class is IFeatureClass && ((IFeatureClass)layer.Class).Envelope != null) { envelope = ((IFeatureClass)layer.Class).Envelope; } else if (layer.Class is IRasterClass && ((IRasterClass)layer.Class).Polygon != null) { envelope = ((IRasterClass)layer.Class).Polygon.Envelope; } if (envelope != null) { if (fullExtent == null) { fullExtent = new Framework.Geometry.Envelope(envelope); } else { fullExtent.Union(envelope); } } } if (fullExtent != null) { BBox = $"{fullExtent.minx.ToDoubleString()},{fullExtent.miny.ToDoubleString()},{fullExtent.maxx.ToDoubleString()},{fullExtent.maxy.ToDoubleString()}"; } } if (map.Display?.SpatialReference != null) { BBoxSRef = map.Display.SpatialReference.Name.ToLower().Replace("epsg:", ""); } Size = "800,600"; } }