React native 世博地图视图的默认位置
我有一张简单的世博地图,如下所示:React native 世博地图视图的默认位置,react-native,maps,expo,React Native,Maps,Expo,我有一张简单的世博地图,如下所示: <MapView loadingEnabled ref = {c => (this.mapView = c)} style={ styles.mapStyle } > {jobsToArray.map(function(item, i){ return <MapView.Marker key={i} coordinate={item}
<MapView
loadingEnabled
ref = {c => (this.mapView = c)}
style={ styles.mapStyle }
>
{jobsToArray.map(function(item, i){
return <MapView.Marker
key={i}
coordinate={item}
>
</MapView.Marker>
})}
<MapViewDirections
mode="DRIVING"
optimizeWaypoints={true} //Make sure route is the fatest possible
origin={this.state.myLocation.coords} //Start location = current location
waypoints={jobsToArray} //Array of destinations to visit
destination={jobsToArray[jobsToArray.length-1]} //Final destination
onReady={result => {
//Show entire map of waypoints with some padding
this.mapView.fitToCoordinates(result.coordinates, {
edgePadding: {
right: width / 20,
bottom: height / 20,
left: width / 20,
top: height / 3
}, animated: true }
);
}}
onError={errorMessage => {
// console.log('GOT AN ERROR');
}}
/>
</MapView>`
(this.mapView=c)}
style={style.mapStyle}
>
{jobstorarray.map(函数(项,i){
返回
})}
{
//使用一些填充显示整个航路点地图
此.mapView.fitToCoordinates(结果.coordinates{
边缘添加:{
右:宽度/20,
底部:高度/20,
左:宽度/20,
顶部:高度/3
},动画:true}
);
}}
OneError={errorMessage=>{
//log('GOT-ERROR');
}}
/>
`
地图动画显示了所有的位置,效果很好,但我只是有点恼火,在我的方向加载之前,地图的起始位置是非洲中部(虽然显示了整个国家),然后对澳大利亚的一个郊区进行了巨大的扫掠动画。有没有话说,先展示澳大利亚(或确切位置),然后再从那里放大
理想情况下,我会显示我们的地图正在使用的状态,然后从那里进行较小的缩放。我希望这是有道理的
谢谢有一些简单的代码可以添加到
MapView
initialRegion={{
纬度:-37.112146,
经度:144.857483,
latitudeDelta:10,
长德尔塔:10,
}}