【发布时间】:2019-07-12 00:57:09
【问题描述】:
我正在尝试将 MapBox 与 React.js 一起使用。这是我的代码:
import ReactMapboxGl, {Layer, Feature} from "react-mapbox-gl";
render() {
const Map = ReactMapboxGl({
accessToken: "..."
});
return (
<div className="App">
<Map style="mapbox://styles/mapbox/streets-v9"
containerStyle={{
height: "100vh",
width: "100vw",
}}>
<Layer
style={{
position: 'absolute',
left: 0,
top: 0,
}}
type="symbol"
id="marker"
layout={{"icon-image": "marker-15"}}>
<Feature coordinates={[-0.481747846041145, 51.3233379650232]}/>
</Layer>
</Map>
{/*<button onClick={this.requestLocation}>Refresh position</button>*/}
</div>
);
}
问题是,结果如下:
它总是正好是宽度的 50%。我正在使用这个模块:https://github.com/alex3165/react-mapbox-gl
我搞砸了什么?
【问题讨论】:
-
这似乎是 React 包装器的一个很常见的问题:github.com/alex3165/react-mapbox-gl/issues/669
标签: javascript css reactjs mapbox mapbox-gl-js