Google maps 缩放或收缩时,如何使地图视图标记保持在给定坐标?
我目前正在使用React Native上的MapView.Marker,现在我可以通过代码设置标记位置,在我像这样放大/缩小或挤压屏幕之前,一切似乎都很好 如上图所示,标记已稍微移出其位置 我用来固定标记的代码是Google maps 缩放或收缩时,如何使地图视图标记保持在给定坐标?,google-maps,react-native,Google Maps,React Native,我目前正在使用React Native上的MapView.Marker,现在我可以通过代码设置标记位置,在我像这样放大/缩小或挤压屏幕之前,一切似乎都很好 如上图所示,标记已稍微移出其位置 我用来固定标记的代码是 onRegionChange = region => { this.setState({ region }) } setMarkerRegion = () => { const
onRegionChange = region => {
this.setState({
region
})
}
setMarkerRegion = () => {
const { region } = this.state;
this.setState({
markerRegion: region,
locationMarked: true,
});
}
<MapView
ref={m => { this.map = m }}
style={{ flex: 10 }}
initialRegion={region}
onRegionChangeComplete={this.onRegionChange}
provider={PROVIDER_GOOGLE}
customMapStyle={customStyles}>
<Marker
coordinate={{
latitude: markerRegion.latitude,
longitude: markerRegion.longitude
}}
style={{ alignSelf: 'center' }}
title={"This is a title <3"}
description={searchLocation}
/>
</MapView>
<TouchableOpacity style={[styles.markerFixed]} onPress={this.setMarkerRegion}>
<Icon name={'map-marker'} color={'white'} type='font-awesome' containerStyle={styles.marker}></Icon>
</TouchableOpacity>
onRegionChange=region=>{
这是我的国家({
区域
})
}
setMarkerRegion=()=>{
const{region}=this.state;
这是我的国家({
markerRegion:区域,
地点:正确,
});
}
{this.map=m}}
style={{flex:10}}
initialRegion={region}
onRegionChangeComplete={this.onRegionChange}
提供者={provider_GOOGLE}
customMapStyle={customStyles}>
我试着在上面搜索,但是只有一个关于原生android的例子,在这种情况下是没有帮助的,任何想法都将不胜感激