Skip to content

Commit

Permalink
feature/map
Browse files Browse the repository at this point in the history
일단 qr추가
#15
  • Loading branch information
moana16 committed Sep 23, 2022
1 parent 4fdfe32 commit 5719238
Show file tree
Hide file tree
Showing 18 changed files with 27,654 additions and 4,563 deletions.
32,017 changes: 27,489 additions & 4,528 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
"@types/navermaps": "^3.0.17",
"axios": "^0.27.2",
"next": "^12.2.5",
"next-qrcode": "^2.2.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-kakao-maps-sdk": "^1.1.3",
"react-naver-maps": "^0.0.13"
"react-naver-maps": "^0.0.13",
"react-qr-reader": "^3.0.0-beta-1"
},
"devDependencies": {
"eslint": "8.21.0",
Expand Down
52 changes: 52 additions & 0 deletions pages/map/_components/KakaoAPIMap.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useState,useRef, useEffect } from 'react';
import { Map,CustomOverlayMap } from 'react-kakao-maps-sdk';

export const KakaoAPIMap = () => {

const mapRef = useRef(null);
const [myLocation, setMyLocation] = useState('');
const latitude=0, longitude=0;
const currentPosition=[];
useEffect(() => {
// geolocation 이용 현재 위치 확인, 위치 미동의 시 기본 위치로 지정
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
setMyLocation({
latitude: position.coords.latitude,
longitude: position.coords.longitude,

});
});
} else {
window.alert('현재 위치를 알 수 없어 기본 위치로 지정합니다.');
setMyLocation({ latitude: 37.4862618, longitude: 127.1222903 });
}
}, []);

useEffect(() => {
if (typeof myLocation !== 'string') {
// 현재 위치 추적
currentPosition = [myLocation.latitude, myLocation.longitude];
console.log(currentPosition[0], currentPosition[1]);
}

});


return (
<Map
center={{ lat: 37.496313, lng: 126.957037 }}
style={{ width: "100%", height: "100vh" }}
>
<CustomOverlayMap position={{ lat: 37.496313, lng: 126.957037 }}>
<div
style={{padding:"10px", backgroundColor:"#fff", color:"#000"}}
>
숭실대학교 SSUMC
</div>
</CustomOverlayMap>
</Map>
)
};

export default KakaoAPIMap;
23 changes: 0 additions & 23 deletions pages/map/_components/NaverAPIMap.jsx

This file was deleted.

15 changes: 11 additions & 4 deletions pages/map/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import styles from "../../styles/Map.module.css";
import NaverAPIMap from "./_components/NaverAPIMap";
import { KakaoAPIMap } from "./_components/KakaoAPIMap";
import Link from 'next/link'
import {useRouter} from 'next/router'


export default function Map() {
const router = useRouter();


return (
<>
<NaverAPIMap/>
<KakaoAPIMap/>
<div className={styles.stardust_container}>
<div className={styles.stardust_black}></div>
<div className={styles.stardust_yellow}></div>
Expand All @@ -20,8 +25,10 @@ export default function Map() {
<div className={styles.button_container}>
<div className={styles.location_btn}></div>
<div className={styles.refresh_btn}></div>
<div className={styles.guide_btn}></div>
<div className={styles.qr_btn}></div>
<div className={styles.guide_btn}><Link href="/"><a></a></Link></div>
<div className={styles.qr_btn} onClick={()=>router.push('/../qrcode')}>

</div>

</div>

Expand Down
16 changes: 16 additions & 0 deletions pages/map/test copy.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useState,useRef, useEffect } from 'react';
import { Map,CustomOverlayMap } from 'react-kakao-maps-sdk';

export const KakaoAPIMap = () => {





return (


);
};

export default KakaoAPIMap;
34 changes: 34 additions & 0 deletions pages/qrcode/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, {useState, useEffect} from "react";
import { QrReader } from "react-qr-reader";

export default function QrcodeScanner () {
const [data, setData] = useState('No result');
const [hasRendered, setHasRendered] = useState(false);
useEffect(() => {
setHasRendered(true)
}, [])

return (
<>
<div>
{hasRendered && (
<QrReader
onResult = {(result, error) =>{
if(!result) {
setData(result?.text);
console.log(result?.text);
}
if(!error) {
console.info(error);
}
}}
styles={{width : '100%'}}>
</QrReader>
)}

</div>
<p>{data}</p>

</>
)
}
Binary file removed public/guide-button.png
Binary file not shown.
10 changes: 10 additions & 0 deletions public/guide-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img-bg-universe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/my-location-button.png
Binary file not shown.
10 changes: 10 additions & 0 deletions public/my-location-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/qr-button.png
Binary file not shown.
10 changes: 10 additions & 0 deletions public/qr-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/refresh-button.png
Binary file not shown.
Loading

0 comments on commit 5719238

Please sign in to comment.