import PropTypes from 'prop-types'; import React from 'react'; import { Linking, Platform, StyleSheet, TouchableOpacity, ViewPropTypes, } from 'react-native'; import MapView from 'react-native-maps'; export default class CustomView extends React.Component { render() { if (this.props.currentMessage.location) { return ( { const url = Platform.select({ ios: `http://maps.apple.com/?ll=${this.props.currentMessage.location.latitude},${this.props.currentMessage.location.longitude}`, android: `http://maps.google.com/?q=${this.props.currentMessage.location.latitude},${this.props.currentMessage.location.longitude}` }); Linking.canOpenURL(url).then(supported => { if (supported) { return Linking.openURL(url); } }).catch(err => { console.error('An error occurred', err); }); }}> ); } return null; } } const styles = StyleSheet.create({ container: { }, mapView: { width: 150, height: 100, borderRadius: 13, margin: 3, }, }); CustomView.defaultProps = { currentMessage: {}, containerStyle: {}, mapViewStyle: {}, }; CustomView.propTypes = { currentMessage: PropTypes.object, containerStyle: ViewPropTypes.style, mapViewStyle: ViewPropTypes.style, };