map.ejs
11.4 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="stylesheets/bootstrap.css" />
<title>Cafe Map</title>
<style>
.navbar {
background-color: #1d2124 !important;
}
.btn-primary {
color: white !important;
}
p {
font-family: "Noto Sans KR", sans-serif;
}
h1 {
font-family: "Noto Sans KR", sans-serif;
}
h4 {
font-family: "Noto Sans KR", sans-serif;
}
h2 {
font-family: "Noto Sans KR", sans-serif;
}
h3 {
font-family: "Noto Sans KR", sans-serif;
}
h5 {
font-family: "Noto Sans KR", sans-serif;
}
.placeinfo_wrap {
position: absolute;
bottom: 28px;
left: -150px;
width: 300px;
}
.placeinfo {
position: relative;
width: 100%;
border-radius: 6px;
border: 1px solid #ccc;
border-bottom: 2px solid #ddd;
padding-bottom: 10px;
background: #fff;
}
.placeinfo:nth-of-type(n) {
border: 0;
box-shadow: 0px 1px 2px #888;
}
.placeinfo_wrap .after {
content: "";
position: relative;
margin-left: -12px;
left: 50%;
width: 22px;
height: 12px;
background: url("https://t1.daumcdn.net/localimg/localimages/07/mapapidoc/vertex_white.png");
}
.placeinfo a,
.placeinfo a:hover,
.placeinfo a:active {
color: #fff;
text-decoration: none;
}
.placeinfo a,
.placeinfo span {
display: block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.placeinfo span {
margin: 5px 5px 0 5px;
cursor: default;
font-size: 13px;
}
.placeinfo .title {
font-weight: bold;
font-size: 14px;
border-radius: 6px 6px 0 0;
margin: -1px -1px 0 -1px;
padding: 10px;
color: #fff;
background: #d95050;
background: #d95050
url(https://t1.daumcdn.net/localimg/localimages/07/mapapidoc/arrow_white.png)
no-repeat right 14px center;
}
.placeinfo .tel {
color: #0f7833;
}
.placeinfo .jibun {
color: #999;
font-size: 11px;
margin-top: 0;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="/"
><img src="images/home.png" width="40" height="40" alt="" />
</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand" href="/"><strong>Home</strong></a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a
class="nav-link"
style="color: #ffffff"
href="#"
data-toggle="modal"
data-target="#profile"
><%=user.nickname%>'s Profile<span class="sr-only"
>(current)</span
></a
>
</li>
<li class="nav-item active">
<a
class="nav-link"
style="color: #ffffff"
href="/"
onclick="signOut();"
>Logout<span class="sr-only">(current)</span></a
>
</li>
<li class="nav-item active">
<a class="nav-link" style="color: #ffffff" href="/recommend"
>Recommend
<span class="sr-only">(current)</span>
</a>
</li>
</ul>
</div>
</nav>
<div class="pricing-header px-3 py-1 pt-md-3 pb-md-1 mx-auto text-center">
<h3 class="display-6 font-weight-bold">Map</h3>
</div>
<section id="carousel-3" class="text-center">
<div class="row">
<div class="col-1"></div>
<div class="col-10">
<div id="map" style="width: 100%; height: 575px"></div>
</div>
<div class="col-1"></div>
</div>
<button type="button" id='Recommend' class="btn btn-primary" onclick="recommend();">추천</button>
<p id='test'></p>
</section>
<script
type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=68cbccbcd6f0fef0a213e62ad37393ee&libraries=services"
></script>
<script>
function recommend(){
$.ajax({
url: '/recommend',
type: 'GET',
success:function (result){
if (result) {
$('#test').html(result.result[0].CAFE_ID);
}
}
});
}
</script>
<script>
var lat = "";
var lon = "";
var placeOverlay = new kakao.maps.CustomOverlay({ zIndex: 1 });
var contentNode = document.createElement("div");
var markers = [];
var currCategory = "CE7"; // 카테고리코드: 카페
var order = 1;
var mapContainer = document.getElementById("map"),
mapOption = {
center: new kakao.maps.LatLng(36.2477502, 127.078164),
level: 3,
};
var map = new kakao.maps.Map(mapContainer, mapOption);
var ps = new kakao.maps.services.Places(map);
kakao.maps.event.addListener(map, "idle", searchPlaces);
contentNode.className = "placeinfo_wrap";
addEventHandle(contentNode, "mousedown", kakao.maps.event.preventMap);
addEventHandle(contentNode, "touchstart", kakao.maps.event.preventMap);
placeOverlay.setContent(contentNode);
function addEventHandle(target, type, callback) {
if (target.addEventListener) {
target.addEventListener(type, callback);
} else {
target.attachEvent("on" + type, callback);
}
}
placeOverlay.setContent(contentNode);
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
lat = position.coords.latitude;
lon = position.coords.longitude;
var locPosition = new kakao.maps.LatLng(lat, lon);
displayCurrentPosition(locPosition);
});
} else {
var locPosition = new kakao.maps.LatLng(36.2477502, 127.078164);
displayCurrentPosition(locPosition);
}
function displayCurrentPosition(locPosition) {
map.setCenter(locPosition);
}
kakao.maps.event.addListener(map, "idle", searchPlaces);
function searchPlaces() {
if (!currCategory) {
return;
}
placeOverlay.setMap(null);
ps.categorySearch(currCategory, placesSearchCB, { usemapBounds: true });
}
function placesSearchCB(data, status, pagination) {
if (pagination.hasNextPage) {
pagination.nextPage();
}
if (status === kakao.maps.services.Status.OK) {
displayPlaces(data);
}
}
function displayPlaces(places) {
for (var i = 0; i < places.length; i++) {
var marker = addMarker(
new kakao.maps.LatLng(places[i].y, places[i].x),
order
);
(function (marker, place) {
kakao.maps.event.addListener(marker, "click", function () {
displayPlaceInfo(place);
});
})(marker, places[i]);
}
}
function addMarker(position, order) {
var imageSrc =
"https://t1.daumcdn.net/localimg/localimages/07/mapapidoc/places_category.png";
var imageSize = new kakao.maps.Size(27, 30);
var imgOptions = {
spriteSize: new kakao.maps.Size(72, 220),
spriteOrigin: new kakao.maps.Point(46, 150),
offset: new kakao.maps.Point(11, 28),
};
var markerImage = new kakao.maps.MarkerImage(
imageSrc,
imageSize,
imgOptions
);
var marker = new kakao.maps.Marker({
position: position,
image: markerImage,
});
marker.setMap(map);
markers.push(marker);
return marker;
}
function displayPlaceInfo(place) {
console.log(place);
var content =
'<div class="placeinfo">' +
' <a class="title" href="' +
place.place_url +
'" target="_blank" title="' +
place.place_name +
'">' +
place.place_name +
"</a>";
if (place.road_address_name) {
content +=
' <span title="' +
place.road_address_name +
'">' +
place.road_address_name +
"</span>" +
' <span class="jibun" title="' +
place.address_name +
'">(지번 : ' +
place.address_name +
")</span>";
} else {
content +=
' <span title="' +
place.address_name +
'">' +
place.address_name +
"</span>";
}
content +=
' <span class="tel">' +
place.phone +
"</span>" +
`<a href="/review/${place.id}"><button>후기 작성</button>`;
"</div>" + '<div class="after"></div>';
contentNode.innerHTML = content;
placeOverlay.setPosition(new kakao.maps.LatLng(place.y, place.x));
placeOverlay.setMap(map);
}
</script>
<script src="javascripts/bootstrap.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<!-- 모달 바디 -->
<div
class="modal fade"
id="profile"
tabindex="-1"
role="dialog"
aria-labelledby="profilemodal"
aria-hidden="true"
>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="profilemodal">
<%=user.nickname%>'s PROFILE
</h5>
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body text-center">
<div class="card mb-3">
<div class="row g-0">
<div class="col-md-4">
<img
src="<%= user.picture%>"
alt="google profile picture"
style="width: 100%; height: 100%"
/>
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title"><%=user.nickname%></h5>
<p class="card-text">
Age : <%=user.age%>, Gender : <%=user.gender%>
</p>
<p class="card-text">Emaile : <%=user.email%></p>
<p class="card-text">
<small class="text-muted"
>from Google and CafeRecommend</small
>
</p>
</div>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-primary" data-dismiss="modal">
확인
</button>
</div>
</div>
</div>
</body>
</html>