当前位置:编程学习 > 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();
    });
});

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,