swa07016

kakao map api 이용 Map 컴포넌트 구현

node_modules
json_datas.json
client/public/images
client/node_modules
\ No newline at end of file
client/node_modules
client/src/config
\ No newline at end of file
......
......@@ -36,7 +36,6 @@ height: 100%;
<body class="pt-5" style="width : 100%; height:100%; margin: 0;">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root" style="width : 100%; height:100%;"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
......
/*global kakao*/
import React, { useEffect } from 'react'
import appKey from '../config/appKey.json';
const Map = (props) => {
useEffect(()=>{
const script = document.createElement("script");
script.async = true;
script.src =
`https://dapi.kakao.com/v2/maps/sdk.js?appkey=${appKey.value}&autoload=false`;
document.head.appendChild(script);
script.onload = () => {
kakao.maps.load(() => {
let container = document.getElementById("myMap");
let options = {
center: new kakao.maps.LatLng(props.latitude, props.longitude),
level: 3
};
const map = new window.kakao.maps.Map(container, options);
let markerPosition = new kakao.maps.LatLng(props.latitude, props.longitude);
let marker = new kakao.maps.Marker({
position: markerPosition
});
marker.setMap(map);
});
};
}
);
return (
<div id='myMap' style={{
'width':'100%',
'height':'25rem'
}}></div>
)
}
export default Map;
\ No newline at end of file
import React, { useState } from 'react';
import { Card, CardBody, CardTitle, CardText, CardImg, CardFooter, Button } from 'reactstrap';
import { Modal, ModalHeader, ModalBody, ModalFooter, Container } from 'reactstrap';
import Map from './Map';
import './MealCard.css';
import { faAngleRight } from "@fortawesome/free-solid-svg-icons"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
const MealCard = (props) => {
const [modal, setModal] = useState(false);
const toggleModal = () => setModal(!modal);
return (
......@@ -66,9 +67,12 @@ const MealCard = (props) => {
<hr className="my-2"/>
{props.address}
<br/>
<Map
latitude = {props.latitude}
longitude = {props.longitude}
/>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</ModalBody>
<ModalFooter>
<div style={{
......
......@@ -51,7 +51,6 @@ const MenuPage = (props) => {
for(let k = 0; k < temp.length; k++) {
if(datas[j].type === temp[k]) {
result.push(datas[j]);
console.log('skr');
}
}
}
......