手动绘制标记点,第二次就不能绘制

0 投票
function addLayer(){
                map.addLayers([layer,vector,markers,vectorLayer]);
                //中心标记点
                this.map.setCenter(new SuperMap.LonLat(116.658086,40.128387),4);
            }
            
            function drawPoint(){
                drawPoint = new SuperMap.Control.DrawFeature(vectorLayer,SuperMap.Handler.Point);
                drawPoint.events.on({"featureadded":drawPointCompeleted});
                map.addControl(drawPoint);
                drawPoint.activate();
            }
            
            function drawPointCompeleted(eventArgs){
                drawPoint.deactivate();
                var geometry = eventArgs.feature.geometry;
                
            }
        </script>
    </head>
    
    <body onload="init()" >
        <input type="button" value="drawPoint" onclick="drawPoint()"/>
        <div id="map"></div>
    </body>

代码是这样子的,第一次点按钮能绘制标记点,第二次点按钮就不能绘制了,就没效果了,为什么
6月 13, 2017 分类:  283次浏览 | 用户: 甜逗 初出茅庐 (22 分)

1个回答

1 投票
 
已采纳

请参考示例,根据你的情况,其实只需要一个DrawFeature控件,不需要每次点击都添加一个,并且添加的都是同一个变量且是激活状态 也没有取消激活
http://support.supermap.com.cn:8090/iserver/iClient/forJavaScript/examples/examples.html#drawGeometr
y

6月 13, 2017 用户: 毛瑞 名扬四海 (1,780 分)
采纳于 6月 13, 2017 用户:甜逗
...