superMap之标绘

superMap样例中有一个标绘demo:

https://iclient.supermap.io/examples/leaflet/editor.html#drawAndModify

原理: leaflet.draw组件

    详细api:https://www.npmjs.com/package/leaflet-draw

代码:

    addDraw()
    var editableLayers
    function addDraw() {
        editableLayers = new L.FeatureGroup();
        map.addLayer(editableLayers);
        var options = {
            position: 'topleft',
            draw: {
                polyline: {},
                polygon: false, // 设为false可关闭面绘制工具
                circle: {},
                rectangle: {},
                marker: {},
                remove: {}
            },
            edit: {
                featureGroup: editableLayers,
                remove: true
            }
        };
        var drawControl = new L.Control.Draw(options);
        map.addControl(drawControl);
        map.on(L.Draw.Event.CREATED, function (e) {
            var layer = e.layer;
            editableLayers.addLayer(layer);
        });
    }

获取标绘的features:

function getFeat() {
        console.log(editableLayers)
        console.log(editableLayers.getLayers())
    }

注意:使用时需要引入leaflet.draw组件,否则会报错:L.Control.Draw is not a...

  引入:

    <script type="text/javascript" include="leaflet.draw" src="../../dist/leaflet/include-leaflet.js"></script>

 

 

 

钻研不易,转载请注明出处......

 

相关文章:

  • 2021-07-01
  • 2021-12-30
  • 2022-12-23
  • 2021-12-29
  • 2021-11-18
  • 2021-09-29
  • 2022-02-12
  • 2021-11-11
猜你喜欢
  • 2021-12-27
  • 2022-12-23
  • 2022-01-31
  • 2022-01-19
  • 2021-10-19
  • 2022-12-23
  • 2021-04-15
相关资源
相似解决方案