首页 > 其他 > 详细

经过简化的画图例子(点,线,多边形)

时间:2017-07-26 01:24:38      阅读:333      评论:0      收藏:0      [点我收藏+]

技术分享

代码:

<html>
<head>
    <meta charset="utf-8">
    <title>图形查询属性</title>
    <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css">
    <script src="http://js.arcgis.com/3.9/"></script>
    <script type="text/javascript">

        var map;//全局map;

        require(["dojo/parser", "dijit/registry", "esri/map", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/toolbars/draw",
        "dijit/form/Button", "dojo/domReady!"],
        function (parser, registry, Map, ArcGISDynamicMapServiceLayer, Draw) {
            parser.parse();
            map = new Map("mapDiv");
            
            /*本地创建的server(动态地图)服务*/
            var url = "http://localhost:6080/arcgis/rest/services/bluechina/MapServer";
            var agoLayer = new ArcGISDynamicMapServiceLayer(url);
            map.addLayer(agoLayer);

            var tb = new Draw(map);             //构建画图工具;
            tb.on("draw-end", doIdentify);      //画图结束后执行doIdentify()方法;

            registry.forEach(function (d)        //为button绑定事件;
            {
                if (d.declaredClass === "dijit.form.Button")
                {
                    d.on("click", activateTool);//click调用activateTool()方法;
                }
            });

            function activateTool()
            {
                var tool = null;
                switch (this.label)
                {
                    case "":
                        tool = "POINT";
                        break;
                    case "线":
                        tool = "POLYLINE";
                        break;
                    case "多边形":
                        tool = "POLYGON";
                        break;
                }
                tb.activate(Draw[tool]); //激活画图工具条;
                map.hideZoomSlider();
            }
            function doIdentify()
            {
                alert("画图完成!");
            }
        });
    </script>
</head>
<body class="claro">
    <button data-dojo-type="dijit/form/Button"></button>
    <button data-dojo-type="dijit/form/Button">线</button>
    <button data-dojo-type="dijit/form/Button">多边形</button>

    <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>
</body>
</html>

 

经过简化的画图例子(点,线,多边形)

原文:http://www.cnblogs.com/tinaluo/p/7237244.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!