Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properties from react-mapbox-gl Feature doesn't set properly #47

Open
jevy-wangfei opened this issue Oct 24, 2019 · 0 comments
Open

properties from react-mapbox-gl Feature doesn't set properly #47

jevy-wangfei opened this issue Oct 24, 2019 · 0 comments
Labels

Comments

@jevy-wangfei
Copy link

jevy-wangfei commented Oct 24, 2019

Adding saved ploygon (created use react-mapbox-gl-draw tool) to react-mapbox-gl, the added ploygon in the mode of none. Have to click two times to choose the ploygon.

After adding a Feature in react-mapbox-gl:

<Feature coordinates={[this.props.coords]}
                     onClick={this.handlePolyClick}
                     onMouseEnter={this.handleMouseEnter}
                     onMouseLeave={this.handleMouseLeave}
                     properties={{active: true, meta: 'feature', mode: 'simple_select'}}
            />

The properties could be read from:

private handlePolyClick = (e: any) => {
    const saved = e.feature;

But the ploygon is not in simple_select mode, and is not been selected. I have to use following code to set the feature been selected:

        drawcontrol[0].add(saved)
        let firstFeature = drawcontrol[0].getAll().features[0] || {}
        drawcontrol[0].changeMode('simple_select', {featureIds:[firstFeature.id]})

The DrawControl properties were set as:

<DrawControl ref={this.mapRef}
                                                    controls={controls}
                                                    styles={drawStyles}
                                                    userProperties={true}
                                                    displayControlsDefault={false}
                                                    onDrawCreate={this.props.onDrawCreate}
                                                    onDrawUpdate={this.props.onDrawUpdate}
                                                    onDrawDelete={this.props.onDrawDelete}
                                                    onDrawModeChange={this.props.onAction}
                                                    onDrawSelectionChange={this.props.onAction}

Am I wrong or there is a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants