lib/display/tile-layer.js
function zoomed () {
    // Get the height and width
    height = el.clientHeight
    width = el.clientWidth

    // Set the map tile size
    tile.size([width, height])

    // Get the current display bounds
    var bounds = display.llBounds()

    // Project the bounds based on the current projection
    var psw = projection(bounds[0])
    var pne = projection(bounds[1])

    // Based the new scale and translation vector off the current one
    var scale = projection.scale() * 2 * Math.PI
    var translate = projection.translate()

    var dx = pne[0] - psw[0]
    var dy = pne[1] - psw[1]

    scale = scale * (1 / Math.max(dx / width, dy / height))
    projection
      .translate([width / 2, height / 2])
      .scale(scale / 2 / Math.PI)

    // Reproject the bounds based on the new scale and translation vector
    psw = projection(bounds[0])
    pne = projection(bounds[1])
    var x = (psw[0] + pne[0]) / 2
    var y = (psw[1] + pne[1]) / 2
    translate = [width - x, height - y]

    // Update the Geo tiles
    tile
      .scale(scale)
      .translate(translate)

    // Get the new set of tiles and render
    renderTiles(tile())
  }
function zoomed () {
    // Get the height and width
    height = el.clientHeight
    width = el.clientWidth

    // Set the map tile size
    tile.size([width, height])

    // Get the current display bounds
    var bounds = display.llBounds()

    // Project the bounds based on the current projection
    var psw = projection(bounds[0])
    var pne = projection(bounds[1])

    // Based the new scale and translation vector off the current one
    var scale = projection.scale() * 2 * Math.PI
    var translate = projection.translate()

    var dx = pne[0] - psw[0]
    var dy = pne[1] - psw[1]

    scale = scale * (1 / Math.max(dx / width, dy / height))
    projection
      .translate([width / 2, height / 2])
      .scale(scale / 2 / Math.PI)

    // Reproject the bounds based on the new scale and translation vector
    psw = projection(bounds[0])
    pne = projection(bounds[1])
    var x = (psw[0] + pne[0]) / 2
    var y = (psw[1] + pne[1]) / 2
    translate = [width - x, height - y]

    // Update the Geo tiles
    tile
      .scale(scale)
      .translate(translate)

    // Get the new set of tiles and render
    renderTiles(tile())
  }
function zoomed ( ) { // Get the height and width height = el . clientHeight width = el . clientWidth // Set the map tile size tile . size ( [ width , height ] ) // Get the current display bounds var bounds = display . llBounds ( ) // Project the bounds based on the current projection var psw = projection ( bounds [ 0 ] ) var pne = projection ( bounds [ 1 ] ) // Based the new scale and translation vector off the current one var scale = projection . scale ( ) * 2 * Math . PI var translate = projection . translate ( ) var dx = pne [ 0 ] - psw [ 0 ] var dy = pne [ 1 ] - psw [ 1 ] scale = scale * ( 1 / Math . max ( dx / width , dy / height ) ) projection . translate ( [ width / 2 , height / 2 ] ) . scale ( scale / 2 / Math . PI ) // Reproject the bounds based on the new scale and translation vector psw = projection ( bounds [ 0 ] ) pne = projection ( bounds [ 1 ] ) var x = ( psw [ 0 ] + pne [ 0 ] ) / 2 var y = ( psw [ 1 ] + pne [ 1 ] ) / 2 translate = [ width - x , height - y ] // Update the Geo tiles tile . scale ( scale ) . translate ( translate ) // Get the new set of tiles and render renderTiles ( tile ( ) ) }
Reload tiles on pan and zoom
Reload tiles on pan and zoom