zoukankan      html  css  js  c++  java
  • 应用ArcGIS Server JavaScript API实现地图卷帘效果实现

    var maskDynamicMapServiceLayer = null;
    var maskDynamicMapServiceLayerDiv = null;
    var pointNumb = 0;
    var alignType = "";
    var mapMouseDownEvent= null;
    var mapMouseMoveEvent = null;
    var mapMouseUpEvent = null;
    var mapDiv = null;
    function initOverlayerContrast(layer)
    {
        maskDynamicMapServiceLayer = layer;
        maskDynamicMapServiceLayerDiv = document.getElementById("map_" + maskDynamicMapServiceLayer.id);
        mapDiv = document.getElementById("map");
        mapDiv.onmousedown = startDragSwipe;    
        map.disablePan();
    }
    
    function destroyOverlayerContrast()
    {
        mapDiv.onmousedown = null;
        mapDiv = null;
        maskDynamicMapServiceLayer = null;
        maskDynamicMapServiceLayerDiv = null;
        map.enablePan();
    }
    
    function startDragSwipe(e) {
        pointNumb = 1;
        var eventObj = window.event || e;
        var x = eventObj.clientX;
        var y = eventObj.clientY;
        maskDynamicMapServiceLayerDiv = document.getElementById("map_" + maskDynamicMapServiceLayer.id);
        mapDiv.onmousemove = moveDragSwipe;
        mapDiv.onmouseup = stopDragSwipe;
        //
        var leftOffset = x;
        var topOffset = y;
        var rightOffset = document.body.clientWidth - x;
        var bottomOffset = document.body.clientHeight - y;
        var minOffset = 0;
        if (leftOffset < rightOffset) {
            minOffset = leftOffset;
            alignType = "left";
        } else {
            minOffset = rightOffset;
            alignType = "right";
        }
        if (topOffset < minOffset) {
            minOffset = topOffset;
            alignType = "top";
        }
        if (bottomOffset < minOffset) {
            minOffset = bottomOffset;
            alignType = "bottom";
        }
        //
        var clip = "rect(auto, auto, auto," + x + "px)";
        if (alignType == "right") {
            clip = "rect(auto, " + x + "px, auto, auto)";
        } else if (alignType == "top") {
            clip = "rect(" + y + "px, auto, auto, auto)";
        } else if (alignType == "bottom") {
            clip = "rect(auto, auto, " + y + "px, auto)";
        }
        maskDynamicMapServiceLayerDiv.style.clip = clip;
    }
    
    function moveDragSwipe(e) {
        var eventObj = window.event || e;
        var x = eventObj.clientX;
        var y = eventObj.clientY;
        //
        if (maskDynamicMapServiceLayerDiv && pointNumb == 1) {        
            var clip = "rect(auto, auto, auto," + x + "px)";
            if (alignType == "right") {
                clip = "rect(auto, " + x + "px, auto, auto)";
            } else if (alignType == "top") {
                clip = "rect(" + y + "px, auto, auto, auto)";
            } else if (alignType == "bottom") {
                clip = "rect(auto, auto, " + y + "px, auto)";
            }
            maskDynamicMapServiceLayerDiv.style.clip = clip;
        }
    }
    
    //
    function stopDragSwipe(evt) {
        if (maskDynamicMapServiceLayerDiv)
        {
            maskDynamicMapServiceLayerDiv.style.clip = "rect(auto, auto, auto, auto)";
        }
        pointNumb = 0;
        mapDiv.onmousemove = null;
        mapDiv.onmouseup = null;
    }
  • 相关阅读:
    阿里云(一)云存储OSS的命令行osscmd的安装和使用
    Zephir入门教程一
    【转载】视频CDN技术原理与流程说明
    博客园页面css样式
    Linux使用imagemagick的convert命令压缩图片、节省服务器空间
    WebSockets Tutorial(教程一)WebSockets简介
    ngx_lua_API 指令详解(四)ngx.exec指令
    Git与GitHub学习笔记(二)提交的一些笔记
    这些万能的文献检索工具,你用了几个?
    干货||科研收藏夹必备35个学术网址
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/5779438.html
Copyright © 2011-2022 走看看