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

posted @ 2013-04-18 10:57  沉默的猿  阅读(312)  评论(0编辑  收藏  举报
AmazingCounters.com
给我写信