-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
71 lines (64 loc) · 1.88 KB
/
App.js
File metadata and controls
71 lines (64 loc) · 1.88 KB
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 { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Button, SafeAreaView } from 'react-native';
import Longdo from 'longdo-map-react-native';
export default function App() {
Longdo.apiKey = 'fortestonlydonotuseinproduction!';
let map;
let loc = { lon: 100.5, lat: 13.7 };
let home = Longdo.object('Marker', loc, { detail: 'Home' });
function onReady() {
console.log('ready ' + new Date());
map.call('Overlays.load', Longdo.object('Overlays.Object', 'A00146852', 'LONGDO'));
}
function onOverlayClick(data) {
if (Longdo.isSameObject(data, home)) {
console.log('At Home');
}
map.call('Overlays.list').then(console.log);
}
function onPressTest1() {
map.call('Overlays.add', home);
map.objectCall(home, 'pop', true);
map.call('location', loc);
}
async function onPressTest2() {
let zoom = await map.call('zoom');
let location = await map.call('location');
alert(location.lon + '\n' + location.lat + '\n' + zoom);
}
return (
<SafeAreaView style={styles.container}>
<Longdo.MapView
ref={r => (map = r)}
layer={Longdo.static('Layers', 'GRAY')}
zoom={15}
zoomRange={{min: 14, max: 16}}
location={{lon: 100.5382, lat: 13.7649}}
// ui={false}
lastView={false}
// language={'en'}
onReady={onReady}
onOverlayClick={onOverlayClick}
/>
<Button
onPress={onPressTest1}
title="Home"
/>
<Button
onPress={onPressTest2}
title="Where am I"
/>
<StatusBar style="auto" />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
// alignItems: 'center', // center not working, use stretch (default value)
justifyContent: 'center',
paddingTop: Platform.OS === 'android' ? 25 : 0,
},
});