The following code should do the trick;
Call adjust***ByPixels(), with delta being the offset in pixels.
static final double GOOGLEOFFSET = 268435456;
static final double GOOGLEOFFSET_RADIUS = GOOGLEOFFSET / Math.PI;
static final double MATHPI_180 = Math.PI/180;
static private final double preLonToX1 = GOOGLEOFFSET_RADIUS * (Math.PI/180);
public final static double LonToX( double lon ) {
return Math.round(GOOGLEOFFSET + preLonToX1 * lon);
}
public final static double LatToY( double lat ) {
return Math.round( GOOGLEOFFSET - GOOGLEOFFSET_RADIUS * Math.log((1 + Math.sin(lat * MATHPI_180)) / (1 - Math.sin(lat * MATHPI_180))) / 2);
}
public final static double XToLon( double x) {
return ((Math.round(x) - GOOGLEOFFSET) / GOOGLEOFFSET_RADIUS) * 180/ Math.PI;
}
public final static double YToLat( double y) {
return (Math.PI / 2 - 2 * Math.atan(Math.exp((Math.round(y) - GOOGLEOFFSET) / GOOGLEOFFSET_RADIUS))) * 180 / Math.PI;
}
public final static double adjustLonByPixels( double lon, int delta, int zoom) {
return XToLon(LonToX(lon) + (delta << (21 - zoom)));
}
public final static double adjustLatByPixels( double lat, int delta, int zoom) {
return YToLat(LatToY(lat) + (delta << (21 - zoom)));
}