private MgByteReader Plot(MapGuideViewerInputModel input, bool useLayout, double?scale) { MgSiteConnection conn = CreateConnection(input); MgMap map = new MgMap(conn); map.Open(input.MapName); MgPoint center = map.ViewCenter; MgCoordinate coord = center.Coordinate; MgMappingService mappingService = (MgMappingService)conn.CreateService(MgServiceType.MappingService); MgDwfVersion dwfVersion = new MgDwfVersion("6.01", "1.2"); MgPlotSpecification plotSpec = new MgPlotSpecification(8.5f, 11f, MgPageUnitsType.Inches, 0f, 0f, 0f, 0f); plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f); MgLayout layout = null; if (useLayout) { MgResourceIdentifier layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout"); layout = new MgLayout(layoutRes, "City of Sheboygan", MgPageUnitsType.Inches); } if (!scale.HasValue) { return(mappingService.GeneratePlot(map, plotSpec, layout, dwfVersion)); } else { MgCoordinate mapCenter = map.GetViewCenter().GetCoordinate(); return(mappingService.GeneratePlot(map, mapCenter, scale.Value, plotSpec, layout, dwfVersion)); } }
private MgByteReader Plot(MapGuideViewerInputModel input, bool useLayout, double? scale) { MgSiteConnection conn = CreateConnection(input); MgMap map = new MgMap(conn); map.Open(input.MapName); MgPoint center = map.ViewCenter; MgCoordinate coord = center.Coordinate; MgMappingService mappingService = (MgMappingService)conn.CreateService(MgServiceType.MappingService); MgDwfVersion dwfVersion = new MgDwfVersion("6.01", "1.2"); MgPlotSpecification plotSpec = new MgPlotSpecification(8.5f, 11f, MgPageUnitsType.Inches, 0f, 0f, 0f, 0f); plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f); MgLayout layout = null; if (useLayout) { MgResourceIdentifier layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout"); layout = new MgLayout(layoutRes, "City of Sheboygan", MgPageUnitsType.Inches); } if (!scale.HasValue) { return mappingService.GeneratePlot(map, plotSpec, layout, dwfVersion); } else { MgCoordinate mapCenter = map.GetViewCenter().GetCoordinate(); return mappingService.GeneratePlot(map, mapCenter, scale.Value, plotSpec, layout, dwfVersion); } }
//---------------------------------------------------------------------------------------- // �� �ܣ� ����ͼ���ΪDWF�ļ� // // �� �ߣ� // // // �� �ڣ�2007.05.# // //----------------------------------------------------------------------------------------- public bool PlotMap() { // ��ȡ��Դ����͵�ͼ������� MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService); MgMappingService mappingService = (MgMappingService)siteConnection.CreateService(MgServiceType.MappingService); // ��ͼ MgMap map = new MgMap(); map.Open(resourceService, "Sheboygan"); // ����DWF��������Ϣ MgDwfVersion dwfVer = new MgDwfVersion("6.01", "1.2"); MgPlotSpecification plotSpec = new MgPlotSpecification(8.5f, 11.0f, MgPageUnitsType.Inches, 0f, 0f, 0f, 0f); plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f); // ���DWF�ļ� MgResourceIdentifier layoutRes = new MgResourceIdentifier("Library://MgTutorial/Layouts/SheboyganMap.PrintLayout"); MgLayout layout = new MgLayout(layoutRes, " DWF�ļ�����ʾ��", MgPageUnitsType.Inches); MgByteReader byteReader = mappingService.GeneratePlot(map, plotSpec, layout, dwfVer); //�����ļ� MgByteSink byteSink = new MgByteSink(byteReader); string filePath = "C:\\Temp\\Map.DWF"; byteSink.ToFile(filePath); return true; }