How to zoom to center of canvas, not to center of context
问题 I have a canvas, size 400 x 400. On it, i have drawn a map area, 200 x 200. I have translated this to the center of the canvas. I can zoom in and out, all is well. But, when i pan, it zooms from the center of my map area. I want it to always zoom from the center of the canvas no matter where the map area is. I think i need to negate the pan coords somehow, but i can't figure it out. Here is my code: var canvas = document.getElementById("myCanvas"); var ctx = canvas.getContext("2d"); var