Files

55 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2017-10-27 17:39:36 +02:00
import React from 'react';
var PropTypes = require('prop-types');
2016-09-27 17:08:55 +02:00
import {
View,
requireNativeComponent,
StyleSheet,
Platform,
NativeModules,
Animated,
findNodeHandle,
} from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
const viewConfig = {
uiViewClassName: 'RCTMapboxAnnotation',
validAttributes: {
coordinate: true,
},
};
const propTypes = {
...View.propTypes,
2016-09-27 17:13:01 +02:00
id: PropTypes.string.isRequired,
2016-09-27 17:08:55 +02:00
title: PropTypes.string,
subtitle: PropTypes.string,
coordinate: PropTypes.shape({
latitude: PropTypes.number.isRequired,
longitude: PropTypes.number.isRequired,
}).isRequired,
};
class MapboxAnnotation extends React.Component {
2016-09-27 17:13:01 +02:00
setNativeProps(nativeProps) {
this.marker.setNativeProps(nativeProps);
}
2016-09-27 17:08:55 +02:00
render() {
return (
<RCTMapboxAnnotation
ref={ref => { this.marker = ref; }}
{...this.props}
/>
);
}
}
MapboxAnnotation.propTypes = propTypes;
MapboxAnnotation.viewConfig = viewConfig;
const RCTMapboxAnnotation = requireNativeComponent('RCTMapboxAnnotation', MapboxAnnotation);
module.exports = MapboxAnnotation;