首页 / 浏览问题 / WebGIS / 问题详情
L.Feature is not a constructor
42EXP 2022年07月13日

请问,leaflet怎么创建一个feature属性呢。

我在标会的时候想把标会的面(多个)存储起来,想存到数据库的一个面里。

但标会的图层layer里没有feature属性,(之前数据库里存的面是有的)我怎么可以自己定义一个feature吗?

没看到怎么定义,直接使用new L.Feature会报错L.Feature is not a constructor。

这个是标会的图层layers = that.map.pm.getGeomanLayers():

let addFeatureParams = new SuperMap.EditFeaturesParameters({

          dataSourceName: GLOBAL.datasource_name,

          dataSetName: "cq_gis_grid",

          features: that.editFeature,

          editType: "ADD",

          returnContent: true

      });

      L.supermap.featureService(GLOBAL.data_url).editFeatures(addFeatureParams, function (serviceResult) {

        if (serviceResult.result.succeed) {

}

}

1个回答

您好,没有太理解您的需求目的到底是什么。

代码控制构造标绘的话可以参考这里,https://iclient.supermap.io/examples/leaflet/editor.html#plot_drawGeoGraphicObject。

希望可以帮助到您。

9,633EXP 2022年07月13日
我想构造feature,可以吗?并且是一个feature里放多个几何面

构造对象的话放到使用标绘的构造方法,比如三角面构造 plottingLayer.createSymbol,type使用SuperMap.Plot.SymbolType.POLYLINESYMBOL。

https://iclient.supermap.io/web/plotting/docs/leaflet/L.supermap.plotting.plottingLayer.html

标绘的数据,使用组件自己就加到图层里了,可以控制加的图层类型吗?我需要保存的是标绘出来的面。,。

openlayer里有ol.feature,feaflet里没有相关的构造方法吗?

如果直接按照普通图层里的feature里面的数据格式去改的话,有些

SMPERIMETER,SMSDRIE,SMSDRIN之类的属性可以为空吗

标绘这里画出来的都是symbol标号,不是点线面几何对象。

所以如果您要在地图上绘制面的话,如果需要添加到标绘图层里,取节点参考该方法构造面类型的标号进行添加。

(不支持复合对象)

        var latlngs = [];
        latlngs.push(new L.latLng(27,101));
        latlngs.push(new L.latLng(34,97));
        latlngs.push(new L.latLng(41,104));
        latlngs.push(new L.latLng(31,115));
        plottingLayer.createSymbol(0, SuperMap.Plot.SymbolType.ARBITRARYPOLYGONSYMBOL, latlngs);

如果要在地图上直接绘制面对象,取节点构造polygon添加,

添加单面对象

        var polygon = L.polygon([[0, 20], [-30, 20], [-10, 50], [0, 20]], {color: 'red'});
        polygon.addTo(map);

添加复合面对象

        var polygon = L.polygon([[[0, 20], [-20, -20], [0, -50], [0, 20]],[[0, 20], [-30, 20], [-10, 50], [0, 20]]], {color: 'red'});
        polygon.addTo(map);

这些图上绘制都不涉及 SMPERIMETER,SMSDRIE,SMSDRIN之类的属性的。

参考:
https://iclient.supermap.io/examples/leaflet/editor.html#plot_drawGeoGraphicObject

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

...