code: function(loc) {
          var data = null,
              x = loc.lon,
              y = loc.lat,
              numRows = this.grid.length;
  
          if (this.map && numRows) {
              var res = this.map.getResolution(),
                  tileWidth = this.tileSize.w,
                  tileHeight = this.tileSize.h,
                  bounds = this.grid[0][0].bounds,
                  left = bounds.left,
                  top = bounds.top;
  
              if (x < left) {
                  // deal with multiple worlds
                  if (this.map.baseLayer.wrapDateLine) {
                      var worldWidth = this.map.getMaxExtent().getWidth();
                      var worldsAway = Math.ceil((left - x) / worldWidth);
                      x += worldWidth * worldsAway;
                  }
              }
              // tile distance to location (fractional number of tiles);
              var dtx = (x - left) / (res * tileWidth);
              var dty = (top - y) / (res * tileHeight);
              // index of tile in grid
              var col = Math.floor(dtx);
              var row = Math.floor(dty);
              if (row >= 0 && row < numRows) {
                  var tile = this.grid[row][col];
                  if (tile) {
                      data = {
                          tile: tile,
                          // pixel index within tile
                          i: Math.floor((dtx - col) * tileWidth),
                          j: Math.floor((dty - row) * tileHeight)
                      };                    
                  }
              }
          }
          return data;
      }
docs: Method: getTileData
  Given a map location, retrieve a tile and the pixel offset within that
  tile corresponding to the location.  If there is not an existing
  tile in the grid that covers the given location, null will be
  returned.
  
  Parameters:
  loc - {<OpenLayers.LonLat>} map location
  
  Returns:
  {Object} Object with the following properties: tile ({<OpenLayers.Tile>}),
  i ({Number} x-pixel offset from top left), and j ({Integer} y-pixel
  offset from top left).