Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 缩放或收缩时,如何使地图视图标记保持在给定坐标?_Google Maps_React Native - Fatal编程技术网

Google maps 缩放或收缩时,如何使地图视图标记保持在给定坐标?

Google maps 缩放或收缩时,如何使地图视图标记保持在给定坐标?,google-maps,react-native,Google Maps,React Native,我目前正在使用React Native上的MapView.Marker,现在我可以通过代码设置标记位置,在我像这样放大/缩小或挤压屏幕之前,一切似乎都很好 如上图所示,标记已稍微移出其位置 我用来固定标记的代码是 onRegionChange = region => { this.setState({ region }) } setMarkerRegion = () => { const

我目前正在使用React Native上的MapView.Marker,现在我可以通过代码设置标记位置,在我像这样放大/缩小或挤压屏幕之前,一切似乎都很好

如上图所示,标记已稍微移出其位置

我用来固定标记的代码是

    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的例子,在这种情况下是没有帮助的,任何想法都将不胜感激