点击Mapbox标记时做出反应更改网址

时间:2019-07-17 07:15:07

标签: reactjs mapbox mapbox-gl

我有一个带有一些标记的mapbox地图,单击标记时我需要更改网址,我使用了react router但它不起作用

<Mapo style="mapbox://styles/mapbox/streets-v9" containerStyle={{ height: "100vh", width: "50vw" }} center={this.state.center} zoom={this.state.zoom} flyToOptions={this.flyToOptions} onDrag={() => this.setState({freelancer: undefined})}>
                <Router>
                    <Link to='{this.state.freelancer}'>
                        <Layer type="circle" id="marker" paint={POSITION_CIRCLE_PAINT}>
                            {
                                this.state.freelancers.map((freelancer) => {
                                    let coordinates = [];
                                    coordinates.push(freelancer.long)
                                    coordinates.push(freelancer.lat)

                                    return (
                                        <Feature key={freelancer} onClick={ () => {this.alertc(freelancer, coordinates)} } coordinates={coordinates} onMouseEnter={this.onToggleHover.bind(this, 'pointer')} onMouseLeave={this.onToggleHover.bind(this, '')}/>
                                    )
                                    }
                                )
                            }
                        </Layer>
                    </Link>
                </Router>
            </Mapo>

0 个答案:

没有答案