forked from react-native-maps/react-native-maps
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPointForCoordinate.js
48 lines (44 loc) · 1.1 KB
/
PointForCoordinate.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
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { NativeModules } from 'react-native';
import MapView from 'react-native-maps';
const { TestModule } = NativeModules;
export default class PointForCoordinateTest extends Component {
async componentDidMount() {
if (TestModule == null) {
throw new Error('TestModule not registered');
}
if (this.map == null) {
throw new Error('MapView ref is null');
}
const point = await this.map.pointForCoordinate({
latitude: 37.78825,
longitude: -122.4324,
});
if (point != null) {
TestModule.markTestCompleted();
} else {
throw new Error(point);
}
}
render() {
const { provider } = this.props;
return (
<MapView
ref={map => {
this.map = map;
}}
provider={provider}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
);
}
}
PointForCoordinateTest.propTypes = {
provider: PropTypes.string,
};