arcgis中一般用InfoTemplate做信息展示,可是这个信息框是固定的。怎么做一个可任意拖动的对话框?
可以参考以下代码:
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
如果对您有帮助,请采纳答案好吗,谢谢!