showEnt.js
2.87 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
var entName = '';
var entType = '';
var entPhoto = '';
var card = '';
function initMap() {
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
searchPlace('department_store','entertainment');
searchPlace('movie_theater','entertainment');
searchPlace('museum','entertainment');
searchPlace('night_club','entertainment');
searchPlace('shopping_mall','entertainment');
searchPlace('zoo','entertainment');
});
}
}
async function searchPlace(str, placeType) {
switch(placeType) {
case 'food':
service.nearbySearch({
location: pos,
radius: 500,
type: [str]
}, await callback_foods);
break;
case 'entertainment':
service.nearbySearch({
location: pos,
radius: 500,
type: [str]
}, await callback_entertainment);
break;
case 'room':
service.nearbySearch({
location: pos,
radius: 500,
type: [str]
}, await callback_rooms);
break;
default:
break;
}
}
function callback_entertainment(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
console.log(results[i]);
result_entertainment.push(result[i])
}
}
}
// const id = result['id'];
// const place_id =result['place_id'];
// const name = result['name'];
// const address = result['vicinity'];
// let category_big = category1
// const category_small = result.types[0];
// const image = "default"
// const rating = result.rating;
// const lng = result.geometry.viewport.ea.j;
// const lat =result.geometry.viewport.la.j;
for(var i=0; i<entList.size(); i++){
entName = result_entertainment[i][name];
entType = result_entertainment[i][category];
// if(result_entertainment[i][photo]==undefined){
// entPhoto = "noimage.png";
// }
// else{
// entPhoto = entList[i][photo];
}
var tmp = '<div class="col-xl-6 col-sm-6 mb-3">'+
'<div class="card text-white bg-light o-hidden h-100">'+
'<div class="card-body"' + ' style="height:350px; background-image:url(' + "'2.jpg'" + '); background-size: 100% 100%; background-repeat: no-repeat;">' + // place photo
// '<div class="mr-5" id="nameDiv">'+entName+'</div>'+ // place name
// '<div class="mr-5" id="typeDiv">'+entType+'</div>'+ // place type
'<div class="mr-5" id="nameDiv">가게이름</div>'+ // place name
'<div class="mr-5" id="typeDiv">타입</div>'+ // place type
'</div>'+
'</div>'+
'</div>';
//card+=tmp;
document.getElementById("cardBody").innerHTML=tmp;