zoukankan      html  css  js  c++  java
  • javascriptAPI 地图窗口特定位置右键显示菜单功能

    地图窗口右键功能,把如下javascript代码写入单独的脚本,直接引入map窗口所在的html页面即可:

    require(["dojo/ready", "dijit/Menu", "dijit/MenuItem", "dijit/CheckedMenuItem", "dijit/MenuSeparator", "dijit/PopupMenuItem"], function(ready, Menu, MenuItem, CheckedMenuItem, MenuSeparator, PopupMenuItem){
         ready(function(){
             var pMenu;
             pMenu = new Menu({
                 targetNodeIds: ["map"]
             });
             pMenu.addChild(new MenuItem({
                 label: "放大",
                 onClick: function(){alert('放大')}
             }));
             pMenu.addChild(new MenuItem({
              label: "缩小",
                 onClick: function(){alert('缩小')}
             }));
     //        pMenu.addChild(new MenuItem({
     //            label: "Menu Item With an icon",
     //            iconClass: "dijitEditorIcon dijitEditorIconCut",
     //            onClick: function(){alert('i was clicked')}
     //        }));
     //        pMenu.addChild(new CheckedMenuItem({
     //            label: "checkable menu item"
     //        }));
     //        pMenu.addChild(new MenuSeparator());
     
    //        var pSubMenu = new Menu();
     //        pSubMenu.addChild(new MenuItem({
     //            label: "Submenu item"
     //        }));
     //        pSubMenu.addChild(new MenuItem({
     //            label: "Submenu item"
     //        }));
     //        pMenu.addChild(new PopupMenuItem({
     //            label: "Submenu",
     //            popup: pSubMenu
     //        }));
     
            pMenu.startup();
         });
     });
    <span id="map">Right click me to get a menu</span>

    具体可以参考:http://dojotoolkit.org/reference-guide/1.7/dijit/Menu.html,该网站实在是屌爆了。

    dojo.require("dijit.Menu");
    
    var pMenu;
    dojo.ready(function(){
          pMenu = new dijit.Menu({
              targetNodeIds:["prog_menu"]
          });
          pMenu.addChild(new dijit.MenuItem({
              label:"Simple menu item"
          }));
          pMenu.addChild(new dijit.MenuItem({
              label:"Disabled menu item",
              disabled: true
          }));
          pMenu.addChild(new dijit.MenuItem({
              label:"Menu Item With an icon",
              iconClass:"dijitEditorIcon dijitEditorIconCut",
              onClick: function(){alert('i was clicked')}
          }));
          pMenu.addChild(new dijit.CheckedMenuItem({
              label: "checkable menu item"
          }));
          pMenu.addChild(new dijit.MenuSeparator());
    
          var pSubMenu = new dijit.Menu();
          pSubMenu.addChild(new dijit.MenuItem({
              label:"Submenu item"
          }));
          pSubMenu.addChild(new dijit.MenuItem({
              label:"Submenu item"
          }));
          pMenu.addChild(new dijit.PopupMenuItem({
              label:"Submenu",
              popup:pSubMenu
          }));
    
          pMenu.startup();
      });
    <span id="prog_menu">Right click me to get a menu</span>

    原文链接:http://blog.csdn.net/muzai/article/details/7981786

  • 相关阅读:
    数组——基础
    程序流程控制——循环结构
    程序流程控制——分支结构
    运算符
    进制
    变 量
    Java中的名称命名规范
    标识符(Identifier)
    保留字(reserved word)
    关键字
  • 原文地址:https://www.cnblogs.com/dwf07223/p/3027955.html
Copyright © 2011-2022 走看看