React MapBox 我无法更改位置

Oha*_*ian 2 reactjs mapbox-gl-js

我正在使用 alex3165/react-mapbox-gl 并且遇到问题。我试图查看 x,y 位置,但它没有改变。不断展示伦敦。我也尝试更改node_module,但结果是相同的。我应该怎么办?

const coordinate=[29.371532589441756,40.896189603433761];

return (
  <div>
      <div className="col-md-7 col-xs-12">
          <div id="map" className="map-sm">
              <Map
                  style="mapbox://styles/mapbox/satellite-v9"
                  zoom={zoom}
                  containerStyle={{
                  height: "100%",
                  width: "100%",
                  center: {position}

                  }}>
                  <Layer
                      type="symbol"
                      id="marker"
                      layout={{ "icon-image": "marker-15" }}>

                  </Layer>
                  <Feature coordinates={coordinate}/>
              </Map>
          </div>
Run Code Online (Sandbox Code Playgroud)

Win*_*Win 5

在组件上使用center属性Map。您只是使用组件设置要在地图上显示的功能Feature,这实际上并没有设置 MapBox 的默认位置。

<Map
    style="mapbox://styles/mapbox/satellite-v9"
    zoom={zoom}
    containerStyle={{
        height: "100%",
        width: "100%",
    }}
    center={coordinate}
>
    <Layer
        type="symbol"
        id="marker"
        layout={{ "icon-image": "marker-15" }}>

    </Layer>
    <Feature coordinates={coordinate}/>
</Map>
Run Code Online (Sandbox Code Playgroud)