【问题标题】:Use React Leaflet Draw from outside of the map从地图外部使用 React Leaflet Draw
【发布时间】:2018-10-04 10:34:46
【问题描述】:

我想自定义最初显示在地图上的绘图图标。

如何从地图外调用每个动作?

我设法通过使用 redux 调用缩放控件并更改缩放状态。 是否有使用 redux 状态和打开或关闭绘图操作的有效选项。

这是编辑控件的当前实现

<Map
                 style={this.leafletMapService.getMapStyle()}
                 selectArea={true}
                 onAreaSelected={(event) => this.handleAreaSelection(event)}
                 boxZoom={false}
                 ref={map => {this.map = map}}
                 center={this.props.center}
                 zoom={this.props.zoom}
                 minZoom={this.props.minZoom}
                 maxZoom={this.props.maxZoom}
                 attributionControl={false}
                 doubleClickZoom={false}
                 zoomControl={false}
                 editable={true}
                 onZoomEnd={this.handleZoomEnd}
                 bounceAtZoomLimits={false}
                 crs={this.leafletMapService.getNonGeographicMapCRS()}
                 dragging={!!this.props.selectedSection}
                 scrollWheelZoom={false}>
                <FeatureGroup>
                    <EditControl position={'topright'}
                                 onCreated={(event) => this.onCreatedHandler(event)}
                                 onEdited={(event) => this.onEditedHandler(event)}
                                 onDeleted={(event) => this.onDeletedHandler(event)}
                    />
                    {this.props.children}
                </FeatureGroup>
            </Map>

【问题讨论】:

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


    【解决方案1】:

    如果你不能这样做,你必须看看这个问题https://github.com/alex3165/react-leaflet-draw/issues/1

      _onDraw = () => {
            // this code is enable drawing polygon.
            this.drawControl._toolbars.draw._modes.polygon.handler.enable();
       }
    
       _onMounted = (drawControl) => {
            this.drawControl = drawControl;
        }
          <FeatureGroup >
             <EditControl
                onMounted={this._onMounted}
        ........ > .....</EditControl>
    

    【讨论】:

      猜你喜欢
      • 2022-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-22
      • 2020-07-14
      • 2020-05-01
      • 1970-01-01
      相关资源
      最近更新 更多