-
Notifications
You must be signed in to change notification settings - Fork 9
/
home.html
226 lines (219 loc) · 6.87 KB
/
home.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Cache-control" content="public" />
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Navigation</title>
<script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
<script src="https://raw.githack.com/jeromeetienne/AR.js/master/aframe/build/aframe-ar.min.js"></script>
<script>
THREEx.ArToolkitContext.baseURL =
"https://raw.githack.com/jeromeetienne/ar.js/master/three.js/";
</script>
<link rel="stylesheet" href="./index.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />
<link rel="icon" href="favicon.png" type="image/gif" sizes="16x16" />
</head>
<body style="margin: 0; overflow: hidden; ">
<a-scene cursor="rayOrigin: mouse; fuse: true; fuseTimeout: 0;" raycaster="objects: [gps-entity-place];"
vr-mode-ui="enabled: false" embedded
arjs="sourceType: webcam; sourceWidth:1280; sourceHeight:960; displayWidth: 1280; displayHeight: 960; debugUIEnabled: false;">
<a-camera gps-camera rotation-reader> </a-camera>
</a-scene>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#routes" style=" position: fixed;
bottom: 0;
width: 100vw;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
">
Where do you want to go
</button>
<div id="routes" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="LargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myLargeModalLabel">Routes</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" style="padding:0"></div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script>
const loadPlaces = function (coords, end) {
// console.log(end);
return loadPlaceFromAPIs(coords, end);
};
// getting places from REST APIs
function loadPlaceFromAPIs(position, end) {
var endpoint = `https://api.openrouteservice.org/v2/directions/foot-walking?api_key=5b3ce3597851110001cf62487ff45692bdc34cdfbc509ce51f522ec0&start=${position.longitude},${position.latitude}&end=${end.long},${end.lat}`;
console.log(endpoint);
return fetch(endpoint)
.then(res => {
return res.json().then(resp => {
var data = [];
data = data.concat(resp.features["0"].geometry.coordinates);
// console.log(data);
return data;
});
})
.catch(err => {
console.error("Error with places API", err);
});
}
</script>
<script>
var navbutton = [
{
name: "KR",
lat: 23.365088,
long: 85.253257
}
];
// var navbutton = [
// {
// name: "Vishwakarma Hostel",
// lat: 25.257578,
// long: 82.985853
// },
// {
// name: "Swatantrata Bhavan",
// lat: 25.260576,
// long: 82.993757
// },
// {
// name: "ADV Grounds",
// lat: 25.259153,
// long: 82.989267
// },
// {
// name: "LC",
// lat: 25.260911,
// long: 82.986833
// },
// {
// name: "CCD",
// lat: 25.258057,
// long: 82.98686
// },
// {
// name: "G1-G11",
// lat: 25.262131,
// long: 82.992954
// },
// {
// name: "LT3",
// lat: 25.260209,
// long: 82.99055
// },
// {
// name: "Technex Office",
// lat: 25.261372,
// long: 82.986774
// },
// {
// name: "Hyderabad Gate",
// lat: 25.262909,
// long: 82.982231
// },
// {
// name: "Visvesvaraya Hostel",
// lat: 25.263038,
// long: 82.983882
// },
// {
// name: "Aryabhatta Hostel",
// lat: 25.263944,
// long: 82.984399
// },
// {
// name: "ABLT",
// lat: 25.263182,
// long: 82.988691
// },
// {
// name: "Vishwanath Temple",
// lat: 25.26568,
// long: 82.989624
// },
// {
// name: "Library",
// lat: 25.261804,
// long: 82.989914
// },
// {
// name: "Girls Hostel",
// lat: 25.261037,
// long: 82.98345
// },
// {
// name: "SC Dey",
// lat: 25.260237,
// long: 82.987016
// },
// {
// name: "Guest House",
// lat: 25.26014,
// long: 82.9848
// }
// ];
$(window).on("load", () => {
navbutton.forEach(button => {
$(".modal-body").append(`<button
lat="${button.lat}"
long="${button.long}"
type="button"
class="list-group-item list-group-item-action"
>
${button.name}
</button>`);
});
function drawpath(end) {
const scene = document.querySelector("a-scene");
return navigator.geolocation.getCurrentPosition(
function (position) {
loadPlaces(position.coords, end).then(places => {
places.forEach(place => {
const latitude = place[1];
const longitude = place[0];
const icon = document.createElement("a-image");
icon.setAttribute(
"gps-entity-place",
`latitude: ${latitude}; longitude: ${longitude};`
);
icon.setAttribute("name", place.name);
icon.setAttribute("src", "./map-marker.png");
icon.setAttribute("scale", "5, 5,5");
scene.appendChild(icon);
});
});
},
err => alert("Error in retrieving position"), // console.error(, err),
{
enableHighAccuracy: true,
maximumAge: 0,
timeout: 27000
}
);
}
$(".modal-body button").click(e => {
$("#routes").modal("hide");
$("a-image").remove();
// console.log($(e.target).attr("lat"));
var end = {
lat: $(e.target).attr("lat"),
long: $(e.target).attr("long")
};
drawpath(end);
});
});
</script>
</body>
</html>