|
1 | 1 | import 'react-native-gesture-handler';
|
2 |
| -import React, {useEffect} from 'react'; |
| 2 | +import React, {useEffect, useRef, useState} from 'react'; |
3 | 3 | import NaverMapView, {Align, Circle, Marker, Path, Polygon, Polyline} from "./map";
|
4 | 4 | import {Image, ImageBackground, PermissionsAndroid, Platform, ScrollView, Text, TouchableOpacity, View} from "react-native";
|
5 | 5 | import {NavigationContainer} from '@react-navigation/native';
|
6 | 6 | import {createBottomTabNavigator} from "@react-navigation/bottom-tabs";
|
7 | 7 | import {createStackNavigator} from "@react-navigation/stack";
|
| 8 | +import { LayerGroup } from './map/index'; |
8 | 9 |
|
9 | 10 | const P0 = {latitude: 37.564362, longitude: 126.977011};
|
10 | 11 | const P1 = {latitude: 37.565051, longitude: 126.978567};
|
@@ -35,19 +36,32 @@ const TextScreen = () => {
|
35 | 36 | }
|
36 | 37 |
|
37 | 38 | const MapViewScreen = ({navigation}) => {
|
| 39 | + const mapView = useRef(null); |
| 40 | + |
38 | 41 | useEffect(() => {
|
39 | 42 | requestLocationPermission();
|
40 | 43 | }, []);
|
41 | 44 |
|
| 45 | + const [enableLayerGroup, setEnableLayerGroup] = useState(true); |
| 46 | + |
42 | 47 | return <>
|
43 |
| - <NaverMapView style={{width: '100%', height: '100%'}} |
| 48 | + <NaverMapView ref={mapView} |
| 49 | + style={{width: '100%', height: '100%'}} |
44 | 50 | showsMyLocationButton={true}
|
45 | 51 | center={{...P0, zoom: 16}}
|
46 | 52 | onTouch={e => console.warn('onTouch', JSON.stringify(e.nativeEvent))}
|
47 | 53 | onCameraChange={e => console.warn('onCameraChange', JSON.stringify(e))}
|
48 | 54 | onMapClick={e => console.warn('onMapClick', JSON.stringify(e))}
|
49 | 55 | useTextureView>
|
50 |
| - <Marker coordinate={P0} onClick={() => console.warn('onClick! p0')} caption={{text: "test caption", align: Align.Left}}/> |
| 56 | + <Marker coordinate={P0} |
| 57 | + onClick={() => { |
| 58 | + console.warn('onClick! p0') |
| 59 | + mapView.current.setLayerGroupEnabled(LayerGroup.LAYER_GROUP_BICYCLE, enableLayerGroup); |
| 60 | + mapView.current.setLayerGroupEnabled(LayerGroup.LAYER_GROUP_TRANSIT, enableLayerGroup); |
| 61 | + setEnableLayerGroup(!enableLayerGroup) |
| 62 | + }} |
| 63 | + caption={{ text: "test caption", align: Align.Left }} |
| 64 | + /> |
51 | 65 | <Marker coordinate={P1} pinColor="blue" zIndex={1000} onClick={() => console.warn('onClick! p1')}/>
|
52 | 66 | <Marker coordinate={P2} pinColor="red" zIndex={100} alpha={0.5} onClick={() => console.warn('onClick! p2')}/>
|
53 | 67 | <Marker coordinate={P4} onClick={() => console.warn('onClick! p4')} image={require("./marker.png")} width={48} height={48}/>
|
|
0 commit comments