private void PrintLayer(IMapLayer layer, MapArgs args) { MapLabelLayer.ClearAllExistingLabels(); //need to do this or labels not drawn on refresh IMapGroup group = layer as IMapGroup; if (group != null) { foreach (IMapLayer subLayer in group.Layers) { PrintLayer(subLayer, args); } } IMapLayer geoLayer = layer; if (geoLayer != null) { if (geoLayer.UseDynamicVisibility) { if (ViewExtents.Width > geoLayer.DynamicVisibilityWidth) { return; // skip the geoLayer if we are zoomed out too far. } } if (geoLayer.IsVisible == false) { return; } geoLayer.DrawRegions(args, new List <Extent> { args.GeographicExtents }); IMapFeatureLayer mfl = geoLayer as IMapFeatureLayer; if (mfl != null) { if (mfl.UseDynamicVisibility) { if (ViewExtents.Width > mfl.DynamicVisibilityWidth) { return; } } if (mfl.ShowLabels && mfl.LabelLayer != null) { if (mfl.LabelLayer.UseDynamicVisibility) { if (ViewExtents.Width > mfl.LabelLayer.DynamicVisibilityWidth) { return; } } mfl.LabelLayer.DrawRegions(args, new List <Extent> { args.GeographicExtents }); } } } }
public static Bitmap GetBitmap(IMapLayer mapLayer, Extent extent, Rectangle rectangle) { Bitmap bmp = new Bitmap(rectangle.Width, rectangle.Height); using (Graphics graphics = Graphics.FromImage(bmp)) { MapArgs mapArgs = new MapArgs(rectangle, extent, graphics); List <Extent> extents = new List <Extent>() { extent }; mapLayer.DrawRegions(mapArgs, extents, false); } return(bmp); }