Arcgis API for JS 之draw

function dr(){
            top.require([
                "esri/map","esri/toolbars/draw","esri/graphic"
            ],function (Map,Draw,Graphic) {
                // var map = new Map();
                //top.mainMap是封装好的,就是map
                var toolbar = new Draw(top.mainMap);
                toolbar.activate(Draw.POLYGON);
                toolbar.on("draw-end",addToMap);

                function addToMap(evt){
                    var symbol = {"color":            
                         [0,0,0,255],"width":1,"type":"esriSLS","style":"esriSLSSolid"};
                    var graphic = new Graphic(evt.geometry, symbol);
                    //top.window.mainMap是封装好的,是map,我这里面的map有点乱。
                    top.window.mainMap.graphics.add(graphic);
                    //关闭绘图工具
                    toolbar.deactivate();
                }
            })

        }

 

你可能感兴趣的:(arcgis,api,for,js)