expo Mapview 的默认位置
Default location of expo Mapview
我有一个像这样的简单世博会地图:
<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>`
地图以动画形式显示所有位置并且效果很好,但我有点生气,因为在我的方向加载之前地图的起始位置是非洲中部(虽然显示整个国家),然后呢澳大利亚郊区的大型动画。无论如何要说,显示澳大利亚(或确切位置)然后从那里放大?
理想情况下,我会显示我们的地图正在使用的状态,然后从那里进行较小的缩放。我希望这是有道理的。
谢谢
有一些简单的代码可以添加到 MapView
initialRegion={{
latitude: -37.112146,
longitude: 144.857483,
latitudeDelta: 10,
longitudeDelta: 10,
}}
我有一个像这样的简单世博会地图:
<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>`
地图以动画形式显示所有位置并且效果很好,但我有点生气,因为在我的方向加载之前地图的起始位置是非洲中部(虽然显示整个国家),然后呢澳大利亚郊区的大型动画。无论如何要说,显示澳大利亚(或确切位置)然后从那里放大?
理想情况下,我会显示我们的地图正在使用的状态,然后从那里进行较小的缩放。我希望这是有道理的。
谢谢
有一些简单的代码可以添加到 MapView
initialRegion={{
latitude: -37.112146,
longitude: 144.857483,
latitudeDelta: 10,
longitudeDelta: 10,
}}