如何在不单击“编辑”按钮的情况下单击多边形本身而启用多边形(geofence)编辑启用

时间:2019-10-14 12:31:52

标签: reactjs react-leaflet react-leaflet-draw

我使用react-leaflet和'react-leaflet-draw'在地图上创建围栏。

我只想单击击剑网本身而不是单击编辑按钮来编辑击剑网。我正在使用geoJson创建击剑网,

任何人都可以告诉我有关允许在编辑模式下使用围栏的属性吗?

render() {
 return (
  <FeatureGroup>
    <EditControl
      position="bottomright"

      edit={{ remove: false }}
      draw={{
        marker: false,
        circle: false,
        rectangle: false,
        polygon: false,
        polyline: false,
        circlemarker: false,
      }}
    />

{Object.values(this.props.geoFenceIdDataMapWithFlipCoordinates).
 map(geoFence => (
      <Polygon
        key={geoFence.id}
        color={`${geoFence.colorCode}`}
        positions={geoFence.geoData.geoJSON.geometry.coordinates[0]}
      />
    ))}

  </FeatureGroup>
   );
   }
}

1 个答案:

答案 0 :(得分:0)

https://www.icampanile.com/reactjs/react-leaflet-and-google-map-layer-with-controls-draw/此URL将具有示例更新_onFeatureGroupReady方法,

leafletGeoJSON.eachLayer((layer) => { leafletFG.addLayer(layer) layer?.editing?.enable()})