forked from nitaliano/react-native-mapbox-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Annotation.js
54 lines (46 loc) · 1.15 KB
/
Annotation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import PropTypes from 'prop-types';
import React from 'react';
import {
View,
ViewPropTypes,
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,
id: PropTypes.string.isRequired,
title: PropTypes.string,
subtitle: PropTypes.string,
coordinate: PropTypes.shape({
latitude: PropTypes.number.isRequired,
longitude: PropTypes.number.isRequired,
}).isRequired,
};
class MapboxAnnotation extends React.Component {
setNativeProps(nativeProps) {
this.marker.setNativeProps(nativeProps);
}
render() {
return (
<RCTMapboxAnnotation
ref={ref => { this.marker = ref; }}
{...this.props}
/>
);
}
}
MapboxAnnotation.propTypes = propTypes;
MapboxAnnotation.viewConfig = viewConfig;
const RCTMapboxAnnotation = requireNativeComponent('RCTMapboxAnnotation', MapboxAnnotation);
module.exports = MapboxAnnotation;