Find a magnifier for the map

Source: Internet
Author: User

<Html>

<Head> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312 "> <title> webpage special effects | www.jscode.cn | --- add a magnifier to the Map </title> <SCRIPT> var shrinkfactor = 5 // left and top position of the thumbnailimage // (distance to the left and top browser-margin, pixels) var thumbleft = 30var thumbtop = 30 // left and top position of the zoomed image // (distance to the left and top browser-margin, pixels) var largel Eft = 300var largetop = 30 // width and height of the enlarged image's sector (visible part, pixels) var clipwidth = 240var clipheight = 160 </SCRIPT> <SCRIPT> var isNav, isIEvar offsetX, offsetYvar selectedObj var largewidth = 0var largeheight = 0 var thumbwidth = Math. floor (largewidth/shrinkfactor) var thumbheight = Math. floor (largeheight/shrinkfactor) var dragimgwidth = Math. floor (clipwidth/shrinkf Actor) var dragimgheight = Math. floor (clipheight/shrinkfactor) var dragimgleft = far + 3var dragimgtop = far + 3 var difleft = Small-margin diftop = largetop-margin var variable var cliptop = 0var clipbottom = cliptop + empty clipleft = 0var clipright = clipleft + clipwidth if (parseInt (navigator. appVersion)> = 4) {if (navigator. appName = "Netscape") {isNav = true} else {isIE = true}} Function setZIndex (obj, zOrder) {obj. zIndex = zOrder} function shiftTo (obj, x, y) {if (isNav) {if (x <= document. thumb. left) {x = document. thumb. left} if (x> = (document. thumb. left + thumbwidth-dragimgwidth-2) {x = document. thumb. left + thumbwidth-dragimgwidth-2} if (y <= document. thumb. top) {y = document. thumb. top} if (y> = (document. thumb. top + thumbheight-dragimgheight-2) {y = document. thumb. top + thumbheight-dragimghei Ght-2} (obj. moveTo (x, y)} else {if (x <= document. all. thumb. style. posLeft) {x = document. all. thumb. style. posLeft} if (x> = (document. all. thumb. style. posLeft + thumbwidth-dragimgwidth-2) {x = document. all. thumb. style. posLeft + thumbwidth-dragimgwidth-2} if (y <= document. all. thumb. style. posTop) {y = document. all. thumb. style. posTop} if (y> = (document. all. thumb. style. posTop + thumbheight-dragimgheight-2) {y = document. all. thumb. Style. posTop + thumbheight-dragimgheight-2} obj. pixelLeft = xobj. pixelTop = y} cliptop = (y-thumbtop) * cursor = cliptop + clipheightclipleft = (x-thumbleft) * shrinkfactorclipright = clipleft + clipwidth if (document. all) {clippoints = "rect (" + cliptop + "" + clipright + "" + clipbottom + "" + clipleft + ")" document. all. large. style. posTop = largetop-cliptopdocument.all.large.style.posLeft = largeleft-clipleft Document. all. large. style. clip = clippoints} if (document. layers) {document. large. top = largetop-cliptopdocument.large.left = largeleft-clipleftdocument.large.clip.left = clipleftdocument. large. clip. right = cliprightdocument. large. clip. top = cliptopdocument. large. clip. bottom = clipbottom} function setSelectedElem (evt) {if (isNav) {var testObjvar clickX = evt. pageXvar clickY = evt. pageYfor (var I = docume Nt. layers. length-1; I> = 0; I --) {testObj = document. layers [I] if (clickX> testObj. left) & (clickX <testObj. left + testObj. clip. width) & (clickY> testObj. top) & (clickY <testObj. top + testObj. clip. height & document. layers [I]. id = "dragimg") {selectedObj = testObjsetZIndex (selectedObj, 100) return }} else {var imgObj = window. event. srcElementif (imgObj. parentElement. id. indexOf ("dragimg ")! =-1) {selectedObj = imgObj. parentElement. stylesetZIndex (selectedObj, 100) return }} selectedObj = nullreturn} function dragIt (evt) {if (selectedObj) {if (isNav) {shiftTo (selectedObj, (evt. pageX-offsetX), (evt. pageY-offsetY)} else {shiftTo (selectedObj, (window. event. clientX-offsetX), (window. event. clientY-offsetY) return false }}} function engage (evt) {setSelectedElem (evt) if (selectedObj) {if (isNav) {offsetX = evt. pageX-selectedObj. leftoffsetY = evt. pageY-selectedObj. top} else {offsetX = window. event. offsetXoffsetY = window. event. offsetY} return false} function release (evt) {if (selectedObj) {setZIndex (selectedObj, 0) selectedObj = null} function setNavEventCapture () {if (isNav) {document. captureEvents (Event. MOUSEDOWN | Event. MOUSEMOVE | Event. MOUSEUP)} function init () {if (document. layers) {var imageurl1_document.large.doc ument. largepic. src largewidth+document.large.document.widthlargeheight?document.large.doc ument. heightthumbwidth = Math. floor (largewidth/shrinkfactor) thumbheight = Math. floor (largeheight/shrinkfactor) document.thumb.doc ument. write ("

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.