相关疑难解决方法(0)

反应原生地图移动到坐标变化

在我的应用程序中,我有谷歌地图。它的实现如下所示。

<MapView style={[styles.mapStyle, { flex: 1, width: this.state.mapWidth }]}
                            initialRegion={{
                                latitude: this.state.latitude,
                                longitude: this.state.longitude,
                                latitudeDelta: 0.1,
                                longitudeDelta: 0.1,
                            }}
                            provider={PROVIDER_GOOGLE}
                            onPress={this.onMapPress.bind(this)}
                            showsUserLocation={true}
                            followsUserLocation={true}
                            showsMyLocationButton={true}
                            showsCompass={true}
                            showsTraffic={true}
                            toolbarEnabled={true}
                            onMapReady={() => this.setState({ width: width - 1 })}
                        >
                            <Marker draggable
                                coordinate={{
                                    latitude: this.state.latitude,
                                    longitude: this.state.longitude,
                                }}
                                onDragEnd={(e) => this.setState({ x: e.nativeEvent.coordinate })}
                            />
                            <Circle
                                center={{
                                    latitude: this.state.latitude,
                                    longitude: this.state.longitude,
                                }}
                                radius={this.state.radius}
                                fillColor='rgba(253, 48, 4,0.5)'
                                strokeColor='rgba(253, 48, 4,1)'
                            />
   </MapView>
Run Code Online (Sandbox Code Playgroud)

当我单击一个按钮时,我会更改地图区域的状态值。

changeRegion(){
    this.setState({ latitude: 6.86, longitude: 6.86 });
}
Run Code Online (Sandbox Code Playgroud)

这成功地改变了地图标记的位置。

我的问题是,地图没有移动到选定的位置。我怎样才能做到这一点?

react-native react-native-maps

0
推荐指数
1
解决办法
3161
查看次数

标签 统计

react-native ×1

react-native-maps ×1