outletglacierapp/static/js/map.js
// Refresh image after a zoom event
Refresh image after a zoom event
Refresh image after a zoom event
function refresh() {
      var t = zoom.translate();
      var s = zoom.scale();
      var tx = t[0],
          ty = t[1];
      ctx.clearRect(0, 0, imageObj.width, imageObj.height);
      ctx.drawImage(imageObj, 
          tx*imageObj.width/width, ty*imageObj.height/height,
          imageObj.width*s, imageObj.height*s);
      svg.selectAll(".x.axis.map").call(xAxis);
      svg.selectAll(".y.axis.map").call(yAxis);
        another clip for non-skewed points on the canvas
       svg.select("defs #canvas-clip").select('rect')
         .attr("transform", "scale(" + 1/s + ")")
         .attr("x",0-t[0])  origin is 0,0
         .attr("y",0-t[1])
  }
function refresh ( ) { var t = zoom . translate ( ) ; var s = zoom . scale ( ) ; var tx = t [ 0 ] , ty = t [ 1 ] ; ctx . clearRect ( 0 , 0 , imageObj . width , imageObj . height ) ; ctx . drawImage ( imageObj , tx * imageObj . width / width , ty * imageObj . height / height , imageObj . width * s , imageObj . height * s ) ; svg . selectAll ( ".x.axis.map" ) . call ( xAxis ) ; svg . selectAll ( ".y.axis.map" ) . call ( yAxis ) ; }
Refresh image after a zoom event
Refresh image after a zoom event
// save and restore because clearRect can reset zoom state // but apparently not ==> commented out for now // ctx.save(); // ctx.restore(); // // // another clip for non-skewed points on the canvas // svg.select("defs #canvas-clip").select('rect') //   .attr("transform", "scale(" + 1/s + ")") //   .attr("x",0-t[0]) // origin is 0,0 //   .attr("y",0-t[1])