Repository navigation
Expand file tree
/
Copy pathveronica.js
More file actions
116 lines (106 loc) · 3.7 KB
/
Copy pathveronica.js
File metadata and controls
116 lines (106 loc) · 3.7 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
'use strict';
var mymap = L.map('mapid').setView([26.35773, 73.0632], 12);
let initialiseMap = function () {
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="http://cartodb.com/attributions">CartoDB</a>',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: 'pk.eyJ1IjoiYWJoaW5hdnJhaSIsImEiOiJjajU3YTduZjMwdjA5MnlwaHU0bnoweDNrIn0.b43RguKtcWbMVJP6jilW6w'
}).addTo(mymap);
}
let plotHotelList = function () {
for (var i = 0; i < hotelList.length; i++) {
let hotel = L.marker([hotelList[i].lat, hotelList[i].lng]).addTo(mymap);
let hotelInfo = "<b>" + "Hotel: </b>" + hotelList[i].name + "<br> <b> Address: </b>" + hotelList[i].address + "<br> <b> Tariff: </b>" + hotelList[i].tarrif + "<br> <b> Contact: </b>" + hotelList[i].contact;
hotel.bindTooltip(hotelInfo);
}
};
let plotCampus = function () {
let permanentCampusLatLng = [26.47649, 73.122371];
let mbmCampusLatLng = [26.27068, 73.034893];
let permanentCampusCircle = L.circle(permanentCampusLatLng, {
color: 'red',
fillColor: 'green',
fillOpacity: 0.5,
radius: 500
}).addTo(mymap);
permanentCampusCircle.bindTooltip("<b>Permanent Campus</b>");
let mbmCampusCircle = L.circle(mbmCampusLatLng, {
color: 'green',
fillColor: 'red',
fillOpacity: 0.5,
radius: 300
}).addTo(mymap);
mbmCampusCircle.bindTooltip("<b>Temporarty Campus (MBM)</b> <br> Bus Journey starts here");
}
let plotTransportations = function () {
let airportLatLng = [26.250152, 73.046908];
let railwayStationLatLng = [26.283607, 73.023029];
let airportIcon = L.icon({
iconUrl: 'images/airport.png',
iconSize: [31, 26]
});
let railwayIcon = L.icon({
iconUrl: 'images/railway.png',
iconSize: [31, 26]
});
let airportMarker = L.marker(airportLatLng, {icon: airportIcon}).addTo(mymap);
let railwayStationMarker = L.marker(railwayStationLatLng, {icon: railwayIcon}).addTo(mymap);
airportMarker.bindTooltip("Airport");
railwayStationMarker.bindTooltip("Railway Station");
};
let latlngPicker = function () {
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(mymap);
}
mymap.on('click', onMapClick);
};
let busSchedule = function () {
let time = new Date();
let hours="";
if (time.getHours()<10)
hours+="0";
hours+=time.getHours();
let minutes = "";
if (time.getMinutes() <10)
minutes+="0";
minutes+=time.getMinutes();
let currentTime = hours+ ":" + minutes;
let lateNightFlag=1;
for (var i=0; i<mbmToKarwad.length; i++){
if (mbmToKarwad[i]>currentTime){
lateNightFlag = 0;
break;
}
}
let nextBusKarwad = mbmToKarwad[0];
if (lateNightFlag == 0){
nextBusKarwad = mbmToKarwad[i];
}
lateNightFlag=1;
for (var i=0; i<karwadToMbm.length; i++){
if (karwadToMbm[i]>currentTime){
lateNightFlag = 0;
break;
}
}
let nextBusMbm = karwadToMbm[0];
if (lateNightFlag == 0){
nextBusMbm = karwadToMbm[i];
}
document.getElementById('karwadBus').innerHTML = nextBusKarwad;
document.getElementById('mbmBus').innerHTML = nextBusMbm;
setTimeout(busSchedule,60000);
}
let init = function () {
initialiseMap();
plotHotelList();
plotCampus();
plotTransportations();
busSchedule();
};
init();