When I draw in the middle of the page and reopen it, the entire diagram move to the upper left corner, making the page have a lot of white space.
I guess the position of the elements isn’t changing. Are you moving the canvas before re-importing?
When I reopen the diagram, I output the information in the console and find that the coordinates have not changed, but the whole diagram has moved to the upper left corner.
There is not guarantee that the canvas will be at the same position with the same zoom after a re-import. What is your expected behavior?
I want the diagram to be displayed in the middle because it looks more friendly.
Have you tried:
var canvas = bpmnViewer.get('canvas'); // zoom to fit full viewport canvas.zoom('fit-viewport');