javascriptAPI 地图窗口任意位置右键显示菜单功能
地图窗口任意位置右键显示菜单功能,把如下javascript代码写入单独的脚本,直接引入map窗口所在的html页面即可:
Creation from markup is even easier. This example creates a context menu for the whole window.
dojo.require("dijit.Menu");
dojo.require("dijit.ColorPalette");
<div data-dojo-type="dijit.Menu" id="windowContextMenu" data-dojo-props="contextMenuForWindow:true" style="display: none;"> <div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconCut', onClick:function(){alert('not actually cutting anything, just a test!')}">Cut</div> <div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconCopy', onClick:function(){alert('not actually copying anything, just a test!')}">Copy</div> <div data-dojo-type="dijit.MenuItem" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconPaste', onClick:function(){alert('not actually pasting anything, just a test!')}">Paste</div> <div data-dojo-type="dijit.MenuSeparator"></div> <div data-dojo-type="dijit.PopupMenuItem"> <span>Enabled Submenu</span> <div data-dojo-type="dijit.Menu" id="submenu1"> <div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('Submenu 1!')}">Submenu Item One</div> <div data-dojo-type="dijit.MenuItem" data-dojo-props="onClick:function(){alert('Submenu 2!')}">Submenu Item Two</div> </div> </div> <div data-dojo-type="dijit.PopupMenuItem"> <span>Popup of something other than a menu</span> <div data-dojo-type="dijit.ColorPalette"></div> </div> </div> <span>Right click anywhere on this page to see a menu</span>
Note that popup menus should be hidden via specifying style=”display: none”.Hiding the menu indirectly via a class won’t work (in that the menu will remain invisible even when it’s supposed to be displayed).
原文链接:http://dojotoolkit.org/reference-guide/1.7/dijit/Menu.html
博客地址: http://www.cnblogs.com/dwf07223,本文以学习、研究和分享为主,欢迎转载,转载请务必保留此出处。若本博文中有不妥或者错误处请不吝赐教。 |