如何在 Mapbox 地图上添加固定标记? (反应)
How to add a fixed marker on a Mapbox map? (React)
我想在 Mapbox 地图上添加一个固定标记。标记应始终居中。
It should look like this
我做了这个解决方法。
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
#marker {
display:block;
position:absolute;
top:50vh;
left:50vw;
z-index:100;
text-align:center;
}
我正在寻找(地图)框之外的东西以避免解决方法。
谢谢!
我只是将地图中心的坐标设置到地图的状态,然后将其传递给标记的道具。
<Layer
type="symbol"
id="marker"
layout={{
'icon-image': 'icon',
}}
>
<Marker anchor="bottom" coordinates={this.state.center} />
</Layer>
我想在 Mapbox 地图上添加一个固定标记。标记应始终居中。
It should look like this
我做了这个解决方法。
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
#marker {
display:block;
position:absolute;
top:50vh;
left:50vw;
z-index:100;
text-align:center;
}
我正在寻找(地图)框之外的东西以避免解决方法。
谢谢!
我只是将地图中心的坐标设置到地图的状态,然后将其传递给标记的道具。
<Layer
type="symbol"
id="marker"
layout={{
'icon-image': 'icon',
}}
>
<Marker anchor="bottom" coordinates={this.state.center} />
</Layer>