javascript - how to rotate a vector based map? -


i need rotate map has been drawn based on vector map using canvas.i use map in navigation system runs in browser.is there simple way follow?

you can context.rotate(angle) method. method not affect drawn on canvas, instead affects drawn after setting rotation. angle in radians, full circle pi * 2 = 6.28318530718.

the rotation around point 0:0 of current internal coordinate system of canvas. recommend use context.translate(x, y) place in center of canvas instead of upper-left corner.

  1. draw map on invisible background canvas
  2. set transformation on visible canvas rotation-center
  3. set rotation on visible canvas
  4. use drawimage draw invisible canvas visible 1 (when use drawimage, source can canvas). drawimage call affected rotation , translation set.

when have control on when , how original map drawn, can alternatively apply transformation , rotation original canvas before drawing it.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -