Index: htdocs/kaMap.js =================================================================== RCS file: /cvs/maptools/cvsroot/ka-map/htdocs/kaMap.js,v retrieving revision 1.66 diff -u -r1.66 kaMap.js --- htdocs/kaMap.js 7 Feb 2006 16:07:46 -0000 1.66 +++ htdocs/kaMap.js 7 Feb 2006 23:46:46 -0000 @@ -1417,6 +1417,9 @@ kaMap.prototype.checkWrap = function() { + // adjust theInsideLayer so it doesn't show more than maxExtents (if set) + this.checkMaxExtents(); + this.xOffset = safeParseInt(this.theInsideLayer.style.left) + this.nCurrentLeft - this.xOrigin; this.yOffset = safeParseInt(this.theInsideLayer.style.top) + this.nCurrentTop - this.yOrigin; @@ -1444,6 +1447,50 @@ } /** + * kaMap.checkMaxExtents() + * + * For maps with maxExtent set, this function adjusts the position of + * theInsideLayer so it never shows more than the maximum extent specified + * in the mapfile. Called from kaMap.checkWrap() since that is called + * with all movement of theInsideLayer + * + * Added by tschaub + */ +kaMap.prototype.checkMaxExtents = function() +{ + var maxExtents = this.getCurrentMap().maxExtents; + if(maxExtents.length == 4) + { + var minLeft = Math.round(this.xOrigin + this.viewportWidth - (maxExtents[2] / this.cellSize)); + var maxLeft = Math.round(this.xOrigin - (maxExtents[0] / this.cellSize)); + var maxTop = Math.round(this.yOrigin - (maxExtents[1] / this.cellSize)); + var minTop = Math.round(this.yOrigin + this.viewportHeight - (maxExtents[3] / this.cellSize)); + // check left and right - both can not be corrected + if(safeParseInt(this.theInsideLayer.style.left) < minLeft) + { + // extra on right + this.theInsideLayer.style.left = Math.round(minLeft) + 'px'; + } + else if(safeParseInt(this.theInsideLayer.style.left) > maxLeft) + { + // extra on left + this.theInsideLayer.style.left = Math.round(maxLeft) + 'px'; + } + // check top and bottom - both can not be corrected + if(safeParseInt(this.theInsideLayer.style.top) < minTop) + { + // extra on bottom + this.theInsideLayer.style.top = Math.round(minTop) + 'px'; + } + else if(safeParseInt(this.theInsideLayer.style.top) > maxTop) + { + // extra on top + this.theInsideLayer.style.top = Math.round(maxTop) + 'px'; + } + } +} + +/** * internal function to reuse extra images * take last image from each row and put it at the beginning */