I calculate my scale on an onExtentChange event using the XY dimensions of the map object (returned by the onExtentChange event) and the size of the mapDiv.
dojo.connect(map, "onExtentChange", updateExtent);
dojo.connect(window, 'resize', mapResize);
pixelPerMeter = 96/.0254; // Define pixel per meter value (96 pixels per inch)
function mapResize(){
var resizeTimer;
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function(){
sizeMap();
map.resize();
map.reposition();
}, 500);
}
function sizeMap(){
mapWidthPx = window.innerWidth;
// Using 57 pixels for control/information bars
mapHeightPx = window.innerHeight - 57;
// Set calculated height for mapDiv
$("#map").css({"height" : (mapHeightPx + "px")});
}
function updateExtent(evt){
mapScale = calcScale(evt.xmax, evt.xmin, evt.ymax, evt.ymin);
displayMapScale(mapScale); // Write map scale out to
}
function calcScale(maxX, minX, maxY, minY) {
var meterX = Math.abs(maxX - minX);
var meterY = Math.abs(maxY - minY);
var scaleX = meterX / mapWidthPx * pixelPerMeter;
var scaleY = meterY / mapHeightPx * pixelPerMeter;
var scaleMin = Math.round((scaleY>scaleX)?scaleX:scaleY);
return scaleMin;
}