Skip to content

Commit e722811

Browse files
authored
Merge pull request #11 from JECT-Study/fix/naver_map_web
Fix/naver map web, vercel 배포 github action
2 parents f56a641 + 50d62c7 commit e722811

6 files changed

Lines changed: 137 additions & 28 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: git push into another repo to deploy to vercel
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
container: pandoc/latex
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Install mustache (to update the date)
15+
run: apk add ruby && gem install mustache
16+
- name: creates output
17+
run: sh ./build.sh
18+
- name: Pushes to another repository
19+
id: push_directory
20+
uses: cpina/github-action-push-to-another-repository@main
21+
env:
22+
API_TOKEN_GITHUB: ${{ secrets.AUTO_ACTIONS }}
23+
with:
24+
source-directory: 'output'
25+
destination-github-username: scorchedrice
26+
destination-repository-name: mycode
27+
user-email: ${{ secrets.EMAIL }}
28+
commit-message: ${{ github.event.commits[0].message }}
29+
target-branch: main
30+
- name: Test get variable exported by push-to-another-repository
31+
run: echo $DESTINATION_CLONED_DIRECTORY

app.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export default {
106106
storybookEnabled: process.env.STORYBOOK_ENABLED,
107107
kakaoNativeAppKey: process.env.MYCODE_KAKAO_NATIVE_APP_KEY,
108108
BACKEND_URL: process.env.MYCODE_BACKEND_URL,
109+
NAVER_MAP_CLIENT_ID: process.env.NAVER_MAP_CLIENT_ID,
109110
eas: {
110111
projectId: process.env.MYCODE_EAS_PROJECT_ID,
111112
},

app/(tabs)/detail/[id].tsx

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { useCallback, useRef, useState } from "react";
22

3-
import {
4-
NaverMapMarkerOverlay,
5-
NaverMapView,
6-
} from "@mj-studio/react-native-naver-map";
73
import { shareFeedTemplate } from "@react-native-kakao/share";
84
import * as Clipboard from "expo-clipboard";
95
import { useFocusEffect, useRouter } from "expo-router";
@@ -22,9 +18,9 @@ import BackArrow from "@/components/icons/BackArrow";
2218
import CopyIcon from "@/components/icons/CopyIcon";
2319
import HeartOutlineIcon from "@/components/icons/HeartOutlineIcon";
2420
import LocationIcon from "@/components/icons/LocationIcon";
25-
import LocationMarkerIcon from "@/components/icons/LocationMarkerIcon";
2621
import LocationPinIcon from "@/components/icons/LocationPinIcon";
2722
import ShareOutlineIcon from "@/components/icons/ShareOutlineIcon";
23+
import NaverMap from "@/components/map/NaverMap";
2824

2925
const SCREEN_HEIGHT = Dimensions.get("window").height;
3026
const IMAGE_HEIGHT = SCREEN_HEIGHT * 0.4;
@@ -325,29 +321,8 @@ export default function DetailScreen() {
325321
위치
326322
</Text>
327323

328-
<View className="mb-3 h-48 overflow-hidden rounded-lg">
329-
<NaverMapView
330-
key={mapKey} // 지도 리셋을 위한 key
331-
style={{ width: "100%", height: "100%" }}
332-
initialCamera={{
333-
latitude: 37.566535,
334-
longitude: 126.9779692,
335-
zoom: 15,
336-
}}
337-
isShowLocationButton={false}
338-
isShowZoomControls={false}
339-
>
340-
<NaverMapMarkerOverlay
341-
latitude={37.566535}
342-
longitude={126.9779692}
343-
width={30}
344-
height={34}
345-
anchor={{ x: 0.5, y: 1 }}
346-
>
347-
<LocationMarkerIcon width={30} height={34} />
348-
</NaverMapMarkerOverlay>
349-
</NaverMapView>
350-
</View>
324+
{/*네이버지도 컴포넌트*/}
325+
<NaverMap mapKey={mapKey} />
351326

352327
<View className="mb-3 flex-row items-center">
353328
<LocationIcon size={16} />

components/map/NaverMap.native.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {
2+
NaverMapMarkerOverlay,
3+
NaverMapView,
4+
} from "@mj-studio/react-native-naver-map";
5+
import { View } from "react-native";
6+
7+
import LocationMarkerIcon from "@/components/icons/LocationMarkerIcon";
8+
9+
export default function NaverMapNative({ mapKey }: { mapKey: number }) {
10+
return (
11+
<View className="mb-3 h-48 overflow-hidden rounded-lg">
12+
<NaverMapView
13+
key={mapKey} // 지도 리셋을 위한 key
14+
style={{ width: "100%", height: "100%" }}
15+
initialCamera={{
16+
latitude: 37.566535,
17+
longitude: 126.9779692,
18+
zoom: 15,
19+
}}
20+
isShowLocationButton={false}
21+
isShowZoomControls={false}
22+
>
23+
<NaverMapMarkerOverlay
24+
latitude={37.566535}
25+
longitude={126.9779692}
26+
width={30}
27+
height={34}
28+
anchor={{ x: 0.5, y: 1 }}
29+
>
30+
<LocationMarkerIcon width={30} height={34} />
31+
</NaverMapMarkerOverlay>
32+
</NaverMapView>
33+
</View>
34+
);
35+
}

components/map/NaverMap.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { JSX } from "react";
2+
3+
import { Platform } from "react-native";
4+
5+
// 타입 명시가 있으면 더 안전
6+
type NaverMapComponent = (props: { mapKey: number }) => JSX.Element;
7+
8+
const loader = Platform.select<() => NaverMapComponent>({
9+
native: () => require("./NaverMap.native").default,
10+
web: () => require("./NaverMap.web").default,
11+
});
12+
13+
const NaverMap = loader ? loader() : () => null; // 함수 그대로 export
14+
15+
export default NaverMap;

components/map/NaverMap.web.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { useEffect } from "react";
2+
3+
import Constants from "expo-constants";
4+
import { View } from "react-native";
5+
6+
declare global {
7+
interface Window {
8+
naver: any;
9+
}
10+
}
11+
12+
export default function NaverMapWeb({ mapKey }: { mapKey: number }) {
13+
const sdkUrl = `https://oapi.map.naver.com/openapi/v3/maps.js?ncpClientId=${Constants.expoConfig?.extra?.NAVER_MAP_CLIENT_ID}`;
14+
useEffect(() => {
15+
const existingScript = document.querySelector(`script[src="${sdkUrl}"]`);
16+
if (existingScript) {
17+
if (window.naver?.maps) {
18+
renderMap();
19+
}
20+
return;
21+
}
22+
23+
const script = document.createElement("script");
24+
script.src = sdkUrl;
25+
script.async = true;
26+
script.onload = () => {
27+
if (window.naver?.maps) {
28+
renderMap();
29+
}
30+
};
31+
document.head.appendChild(script);
32+
}, [mapKey, sdkUrl]);
33+
const renderMap = () => {
34+
const map = new window.naver.maps.Map("map", {
35+
center: new window.naver.maps.LatLng(37.5665, 126.978),
36+
zoom: 15,
37+
});
38+
39+
new window.naver.maps.Marker({
40+
position: new window.naver.maps.LatLng(37.5665, 126.978),
41+
map,
42+
});
43+
};
44+
return (
45+
<View className="mb-3 h-48 overflow-hidden rounded-lg">
46+
<View
47+
id="map"
48+
style={{ width: "100%", height: "100%", borderRadius: 12 }}
49+
/>
50+
</View>
51+
);
52+
}

0 commit comments

Comments
 (0)