-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAMapMarker.js
71 lines (67 loc) · 1.7 KB
/
AMapMarker.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import PropTypes from 'prop-types';
import React, { Component } from 'react'
import {
requireNativeComponent,
View,
UIManager,
findNodeHandle,
ViewPropTypes,
} from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
class MapMarker extends Component {
constructor(props) {
super(props);
this._onPress = this._onPress.bind(this)
}
_onPress(event: Event) {
if (this.props.onPress) this.props.onPress(event.nativeEvent)
}
render() {
let image
if (this.props.image) {
image = resolveAssetSource(this.props.image) || {}
image = image.uri;
}
return (
<AMapMarker
{...this.props}
onPress={this._onPress}
image={image}
/>
)
}
}
MapMarker.propTypes = {
...ViewPropTypes,
identifier: PropTypes.string,
reuseIdentifier: PropTypes.string,
title: PropTypes.string,
description: PropTypes.string,
image: PropTypes.any,
opacity: PropTypes.number,
pinColor: PropTypes.string,
coordinate: PropTypes.shape({
latitude: PropTypes.number.isRequired,
longitude: PropTypes.number.isRequired,
}).isRequired,
centerOffset: PropTypes.shape({
x: PropTypes.number.isRequired,
y: PropTypes.number.isRequired,
}),
anchor: PropTypes.shape({
x: PropTypes.number.isRequired,
y: PropTypes.number.isRequired,
}),
flat: PropTypes.bool,
draggable: PropTypes.bool,
onPress: PropTypes.func,
onSelect: PropTypes.func,
onDeselect: PropTypes.func,
onDragStart: PropTypes.func,
onDrag: PropTypes.func,
onDragEnd: PropTypes.func,
};
var AMapMarker = requireNativeComponent(`AMapMarker`, MapMarker, {
nativeOnly: {onChange: true}
});
module.exports = MapMarker;