Change canvas background

Hi there

How can I change the background of canvas to an image(like a map) where I can drag and drop my custom elements to any place of a map
Screenshot%20from%202019-09-06%2009-20-47

What’s preventing you from doing that?

Sir I don’t know how to change the canvas background. What file should I modify? Is it the Viewer?

You can get the container element using canvas.getContainer() and the SVG through canvas._svg. Apart from that you can use whatever you fancy to change the background.

1 Like

Sir where can I set the canvas background? I have no idea which file should I modify

What about simply using css?


.djs-container {
    background: /** do whathever you want **/
}

Sir, the image won’t be able to zoom in/out when I set it to css. How can I achieve that?
Thanks
Screenshot%20from%202019-09-10%2013-03-55

What are you trying to do? Are you sure bpmn-js is the right tool?

It’s my custom modeler based on diagram-js. I want to drag and drop my custom elements to any place of a map where I can also zoom in/out the background(map) and when I download the diagram, the map also includes in the xml file. It’s only a prototype.

I see. There is no such functionality in diagram-js. you’d have to build it.