React Native Mapbox gl初始中心坐标

时间:2017-01-08 17:21:54

标签: ios react-native mapbox mapbox-gl react-native-mapbox-gl

所以我试图为mapbox设置我的初始中心坐标,所以它们不是0,0。在api上,它表示mapbox需要支持

initialCenterCoordinate object  Optional    Initial latitude/longitude the map will load at.    { latitude:0, longitude: 0 }

所以我在做

<Mapbox
    initialCenterCoordinate={latitude: 40.444328, longitude: -79.953155} .... other props/>

这给了我一行错误,说出意想不到的令牌,期待}。

每当我做

之类的事情
<Mapbox
    initialCenterCoordinate={{latitude: 40.444328, longitude: -79.953155}} .... other props/>

它仍将我的初始位置设为0,0。有人有什么想法吗?

编辑: 链接到git hub page- https://github.com/mapbox/react-native-mapbox-gl

3 个答案:

答案 0 :(得分:0)

在构造函数中尝试使用:

const

并且:

this.state = {
     position : {
        latitude: 49.437090,
        longitude: 1.097456,
     }
};

答案 1 :(得分:0)

根据docs,值应为数组

 <Mapbox
     initialCenterCoordinate={[40.444328, -79.953155]} .... other props/>

答案 2 :(得分:0)

尝试一下:

<MapboxGL.MapView
  key='mainmap'
  style={{ flex: 1 }}>

   <MapboxGL.Camera
     zoomLevel={2}
     centerCoordinate={[2.21, 46.22]}/>

<MapboxGL.MapView />
相关问题