简体   繁体   English

有没有办法在传单地图上编辑现有的geojson数据

[英]Is there any way to edit existing geojson data on the leaflet-map

I want to make edit support for currently displayed geojson polygon layers on the leaflet map.我想为传单地图上当前显示的 geojson 多边形图层提供编辑支持。 When editing button is pressed it gives me当按下编辑按钮时,它给了我

Uncaught TypeError: Cannot read property 'lat' of null未捕获的类型错误:无法读取 null 的属性“lat”

Here is my code:这是我的代码:

 const leafletGeoJSON = new L.GeoJSON(arr, { style(feature: any) { const temp = getColor(feature.properties.id); return { color: temp, fillColor: temp }; }, onEachFeature(feature, layer) { layer.bindTooltip(feature.properties.description); } }); leafletGeoJSON.eachLayer(layer => { reactRef.leafletElement.addLayer(layer); });

I use the leaflet-draw我使用传单抽奖

II finally found the root cause because of we are using Multipolyon on DB I just render as it is but in fact leaflet-draw is not support MultiPolygon I changed data structure to Polygon then now everything works fine.我终于找到了根本原因,因为我们在 DB 上使用 Multipolyon 我只是按原样渲染但实际上传单绘制不支持 MultiPolygon 我将数据结构更改为 Polygon 然后现在一切正常。

The key here is the featureGroup option.这里的关键是 featureGroup 选项。 This tells the plugin which FeatureGroup contains the layers that should be editable.这会告诉插件哪个 FeatureGroup 包含应该可编辑的图层。 The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon. featureGroup 可以包含 0 个或多个几何类型为 Point、LineString 和 Polygon 的要素。 Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection. Leaflet.draw 不适用于多几何特征,例如 MultiPoint、MultiLineString、MultiPolygon 或 GeometryCollection。 If you need to add multigeometry features to the draw plugin, convert them to a FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).如果您需要向绘图插件添加多几何特征,请将它们转换为非多几何(点、线串或多边形)的 FeatureCollection。

https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#l-draw-feature https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html#l-draw-feature

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM