arcgis for js 개발 시리즈의 지도 오른쪽 클릭 이벤트 구현

3461 단어
Simple Map document.oncontextmenu = function (e) { e.preventDefault(); }; require([ "esri/map", "esri/geometry/Point", "esri/SpatialReference","esri/toolbars/edit", "esri/symbols/SimpleMarkerSymbol", "esri/graphic", "esri/InfoTemplate","dijit/Menu", "dijit/MenuItem", "dijit/MenuSeparator", ], function (Map, Point, SpatialReference, SimpleMarkerSymbol, Graphic, InfoTemplate,Edit, Menu, MenuItem, MenuSeparator) { map = new Map("mapDiv", { basemap:"osm", center: [117.12277857421876, 36.632967052981364], zoom: 10, logo: false }); /* var parcelsURL = "http://127.0.0.1:6080/arcgis/rest/services/China/MapServer"; map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer(parcelsURL));*/ map.on("load", doh); function doh() { var point = new Point(117.12277857421876, 36.632967052981364, new SpatialReference({wkid: 4326})); var symbol = new esri.symbol.PictureMarkerSymbol("http://lbsyun.baidu.com/jsdemo/img/fox.gif", 80, 80); var graphic = new esri.Graphic(point, symbol/*,attr,infoTemplate*/); map.graphics.add(graphic); dojo.connect(map.graphics,"onMouseDown",function (e) { if(e.button == 2){ ctxMenuForGraphics = new Menu({}); createGraphicsMenu(e); // ctxMenuForGraphics.bindDomNode(e.graphic.getDojoShape().getNode()); } }) function createGraphicsMenu(e) { ctxMenuForGraphics.addChild(new MenuItem({ label: "<a><img src=\"http://lbsyun.baidu.com/jsdemo/img/fox.gif\" style='width: 30px; height: 30px; vertical-align: middle;'> </a>", onClick: function () { } })); ctxMenuForGraphics.addChild(new MenuItem({ label: "<a><img src=\"http://lbsyun.baidu.com/jsdemo/img/fox.gif\" style='width: 30px; height: 30px; vertical-align: middle;'> </a>", onClick: function () { } })); ctxMenuForGraphics.addChild(new MenuItem({ label: "<a><img src=\"http://lbsyun.baidu.com/jsdemo/img/fox.gif\" style='width: 30px; height: 30px; vertical-align: middle;'> </a>", onClick: function () { alert("Not implemented"); } })); ctxMenuForGraphics.startup(); } } });

좋은 웹페이지 즐겨찾기