code: function (lonlat, resolution) {
          var px = null; 
          if (lonlat != null) {
              resolution = resolution || this.map.getResolution();
              var extent = this.map.calculateBounds(null, resolution);
              px = new OpenLayers.Pixel(
                  (1/resolution * (lonlat.lon - extent.left)),
                  (1/resolution * (extent.top - lonlat.lat))
              );    
          }
          return px;
      }
docs: APIMethod: getViewPortPxFromLonLat
  Returns a pixel location given a map location.  This method will return
  fractional pixel values.
  
  Parameters:
  lonlat - {<OpenLayers.LonLat>|Object} An OpenLayers.LonLat or
  an object with a 'lon'
  and 'lat' properties.
  
  Returns:
  {<OpenLayers.Pixel>} An <OpenLayers.Pixel> which is the passed-in
  lonlat translated into view port pixels.