Tengo un problema con react-native-maps e iOS. En mi pantalla tengo un MapView y un modal con GooglePlacesAutoComplete . Cada vez que escribo una dirección en la función de autocompletar, aparece un marcador en MapView que apunta a la ubicación.
Si quiero arrastrar ese pin a otra ubicación, la dirección cambia. Sin embargo, cuando quiero presionar mi botón Submit para pasar a la siguiente pantalla después del cambio de dirección, no sucede nada.
Mi MapView se ve así:
<ScrollView> <View style={mapViewStyle}> <MapView provider={PROVIDER_GOOGLE} initialRegion={initialRegionMap} region={initialRegionMap} style={StyleSheet.absoluteFillObject} showsUserLocation > {eventLocation && ( <Marker coordinate={eventLocation} title={eventAddress} draggable onDragEnd={e => onMarkerDragEnd(e.nativeEvent.coordinate)} /> )} </MapView> </View> <Button text="Submit" style={saveButtonStyle} onPress={registerNewEvent} /> </ScrollView>Mi función onMarkerDragEnd se ve así:
onMarkerDragEnd = coord => { const { initialRegionMap } = this.state; const newInitialRegion = { ...initialRegionMap }; Geocoder.from(coord).then(json => { const { location } = json.results[0].geometry; const { lat, lng } = location; const geohashValue = geohash.encode(lat, lng); const address0 = json.results[0].address_components[1].long_name; const address1 = json.results[0].address_components[2].long_name; const address2 = json.results[0].address_components[3].long_name; const address3 = json.results[0].address_components[4].short_name; const address4 = json.results[0].address_components[5].long_name; const address5 = json.results[0].address_components[0].long_name; const address = `${address5}, ${address0}, ${address1}, ${address2}, ${address3}, ${address4}`; newInitialRegion.latitude = lat; newInitialRegion.longitude = lng; this.setState({ eventLocation: { latitude: lat, longitude: lng }, eventGeohash: geohashValue, initialRegionMap: newInitialRegion, eventAddress: address }); }).catch(error => { console.log(error); }); } Button es un componente personalizado que hice en base a TouchableOpacity . Intentar cambiar el componente a una ejecución del molino TouchableOpacity no parece funcionar.
También trato de codificar el botón de esta manera:
<Button text="Submit" style={saveButtonStyle} onPress={() => registerNewEvent()} />pero tampoco dados.