var flexElement; /** * 功能:页面加载时执行此方法 * @return flexElement */ function init(){ //var f = parent.frmMainChild.document.getElementsByTagName("object")[0].id; //getmapSWF(f);//选择对象 getmapSWF(); } /** * 功能:地图标注相关方法 * iframe中调用 */ function getmapSWF() { if (navigator.appName.indexOf("Microsoft") != -1) { flexElement = parent.frmMainChild.document.getElementById('FlexProject'); }else{ flexElement = parent.frmMainChild.document.getElementsByTagName("embed")[0]; } wheel(flexElement,afterwheel,true); } /** * 获取用于标注地图的对象 * 父页面调用 */ function getSWF() { if (navigator.appName.indexOf("Microsoft") != -1) { flexElement = document.getElementById("frmMainChild").contentWindow.document.getElementById('FlexProject'); }else{ flexElement = document.getElementById("frmMainChild").contentWindow.document.getElementsByTagName("embed")[0]; } wheel(flexElement,afterwheel,true); return flexElement; } /** * 鼠标滚轮定点放大的方法 * @param obj * @param fn * @param useCapture * @return */ function wheel(obj, fn ,useCapture){ var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel" ; //FF doesn't recognize mousewheel as of FF3.x if (obj.attachEvent) //if IE (and Opera depending on user setting) obj.attachEvent("on"+mousewheelevt, handler, useCapture); else if (obj.addEventListener) //WC3 browsers obj.addEventListener(mousewheelevt, handler, useCapture); function handler(event) { var delta = 0; var event = window.event || event ; var delta = event.detail ? -event.detail/3 : event.wheelDelta/120; if (event.preventDefault) event.preventDefault(); event.returnValue = false; return fn.apply(obj, [event, delta,obj]); } } function afterwheel(event, delta,obj){ //这个是FLEX里写的放大缩小方法 obj.WheelScroll(delta); } function changeLayers(layerI){ // alert(layerI); if(layerI==1){ map.style.backgroundImage = "url(\"/nwyj/page/bin-release/assets/images/mapbg.jpg\")"; }else { map.style.backgroundImage = ""; } }