ARCGIS for JS中如何做可拖动的对话框? 2C

arcgis中一般用InfoTemplate做信息展示,可是这个信息框是固定的。怎么做一个可任意拖动的对话框?

1个回答

可以参考以下代码:

require([  
    "esri/arcgis/utils",   
    "dojo/dnd/Moveable"  
], function (arcgisUtils, Movable) {  
    "use strict";  
    var mapId = "bc6e18b0c332407e800c234de472939f"; // Replace with your own map ID from ArcGIS.com.  

    /** 
     * Makes the popup draggable. 
     * @returns {dojo/dnd/Movable} 
     */  
    function makePopupDraggable(){  
        var popupDiv = document.querySelector(".esriPopup");  
        var dnd;  
        if (popupDiv) {  
            dnd = new Movable(popupDiv);  
        }  
        // TODO: Figure out how to make the little arrow point the right way after dragging.  
        return dnd;  
    }  

    arcgisUtils.createMap(mapId, "map", {  
        usePopupManager: true,  
        mapOptions: {  
            center: [-120.80566406246835, 47.41322033015946],  
            zoom: 7,  
            minZoom: 7  
        }  
    }).then(makePopupDraggable);  

});

这种方法需要借助 dojo.dnd.Moveable
其网址为:

http://dojotoolkit.org/reference-guide/1.7/dojo/dnd/Moveable.html#dojo-dnd-moveable

如果对您有帮助,请采纳答案好吗,谢谢!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!