Files
react-native-mapbox-gl/Annotation.js
T

55 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

import PropTypes from 'prop-types';
import React from 'react';
2016-09-27 17:08:55 +02:00
import {
View,
ViewPropTypes,
2016-09-27 17:08:55 +02:00
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 = {
...ViewPropTypes,
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;