/ Annotation.js
Annotation.js
1 import React from 'react'; 2 var PropTypes = require('prop-types'); 3 4 import { 5 View, 6 requireNativeComponent, 7 StyleSheet, 8 Platform, 9 NativeModules, 10 Animated, 11 findNodeHandle, 12 } from 'react-native'; 13 14 import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'; 15 16 const viewConfig = { 17 uiViewClassName: 'RCTMapboxAnnotation', 18 validAttributes: { 19 coordinate: true, 20 }, 21 }; 22 23 const propTypes = { 24 ...View.propTypes, 25 id: PropTypes.string.isRequired, 26 title: PropTypes.string, 27 subtitle: PropTypes.string, 28 coordinate: PropTypes.shape({ 29 latitude: PropTypes.number.isRequired, 30 longitude: PropTypes.number.isRequired, 31 }).isRequired, 32 33 }; 34 35 class MapboxAnnotation extends React.Component { 36 setNativeProps(nativeProps) { 37 this.marker.setNativeProps(nativeProps); 38 } 39 40 render() { 41 return ( 42 <RCTMapboxAnnotation 43 ref={ref => { this.marker = ref; }} 44 {...this.props} 45 /> 46 ); 47 } 48 } 49 50 MapboxAnnotation.propTypes = propTypes; 51 MapboxAnnotation.viewConfig = viewConfig; 52 53 const RCTMapboxAnnotation = requireNativeComponent('RCTMapboxAnnotation', MapboxAnnotation); 54 module.exports = MapboxAnnotation;