我正在尝试将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
我搞砸了什么?
对不起,您回答的太晚了,这是由于CSS冲突引起的。尝试评论.App的文本对齐中心
.App {
/* text-align: center; */
}
这应该工作!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句