我使用以下代码但没有成功:
//在NativeBase容器内部
<MapView.Animated
ref="map"
style = {styles.map}
showsUserLocation = {true}
zoomEnabled = {true}
showsMyLocationButton = {true}
showsCompass = {true}
showScale = {true}
showsIndoors = {true}
mapType = {this.state.mapTypes[this.state.mapTypeCode]}
/>
Run Code Online (Sandbox Code Playgroud)
//在类的componentDidMount内部
navigator.geolocation.getCurrentPosition(
(position) => {
var initialPosition = JSON.stringify(position.coords);
this.setState({position: initialPosition});
let tempCoords = {
latitude: Number(position.coords.latitude),
longitude: Number(position.coords.longitude)
}
this.refs.map.animateToCoordinate(tempCoords, 1);
}, function (error) { alert(error) },
);
Run Code Online (Sandbox Code Playgroud)
但是发生了一个错误,说没有这样的函数animateToCoordinate.
javascript google-maps react-native react-redux react-native-maps