-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
228 lines (193 loc) · 7.9 KB
/
index.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
227
228
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Map with Google Sheets Data</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine/dist/leaflet-routing-machine.css"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css"/>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
width: 100vw;
}
.leaflet-control-attribution {
display: none;
}
.leaflet-control-reload {
background-color: #fff;
border: 1px solid #ddd;
border-radius: 5px;
padding: 6px;
text-align: center;
cursor: pointer;
}
.leaflet-control-reload:hover {
background-color: #f0f0f0;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">nearbywork</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="collapse" data-bs-target="#aboutSection">home(candidates)</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="collapse" data-bs-target="#contactSection">employeers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="collapse" data-bs-target="#jobpostSection">job post</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" data-bs-toggle="collapse" data-bs-target="#resumepostSection">resume post</a>
</li>
</ul>
</div>
</nav>
<div class="collapse" id="aboutSection">
<div class="card card-body position-relative">
<button type="button" class="btn-close position-absolute top-0 end-0 m-2" data-bs-toggle="collapse" data-bs-target="#aboutSection" aria-label="Close"></button>
<h5>About Us</h5>
<p>This is the About section content.</p>
</div>
</div>
<div class="collapse" id="contactSection">
<div class="card card-body position-relative">
<button type="button" class="btn-close position-absolute top-0 end-0 m-2" data-bs-toggle="collapse" data-bs-target="#contactSection" aria-label="Close"></button>
<h5>Contact Us</h5>
<p>This is the Contact section content.</p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<div id="map"></div>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>
<script src="https://unpkg.com/leaflet-routing-machine/dist/leaflet-routing-machine.js"></script>
<script>
// Initialize the map
const map = L.map('map', {
attributionControl: false // Disable the default attribution control
}).setView([17.4065, 78.4772], 10); // Centered on Hyderabad
// Add a tile layer
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'rishi ralla'
}).addTo(map);
// Fetch the JSON data from Google Sheets
fetch('https://docs.google.com/spreadsheets/d/1ajnO27PRxnHSQiRhyVpukeir-zqTcUfK7F_kfM1nfkc/gviz/tq?tqx=out:json')
.then(response => response.text())
.then(text => {
// Parse the JSON data
const json = JSON.parse(text.substring(47).slice(0, -2)); // Remove callback function and trailing })
const rows = json.table.rows;
// Loop through the rows and add markers
rows.forEach(row => {
const timestamp = row.c[0] ? row.c[0].v : ''; // Timestamp
const title = row.c[1] ? row.c[1].v : ''; // Title
const description = row.c[2] ? row.c[2].v : ''; // Description
const lat = parseFloat(row.c[3].v); // Latitude
const lng = parseFloat(row.c[4].v); // Longitude
const imageUrl = row.c[5] ? row.c[5].v : ''; // Image URL
const workcharges = row.c[6] ? row.c[6].v : ''; // work charges
const callme = row.c[7] ? row.c[7].v : ''; // call
if (!isNaN(lat) && !isNaN(lng)) {
const popupContent = `
<div class="popup-content">
<h4>${title}</h4>
<p>${description}</p>
${imageUrl ? `<img src="${imageUrl}" alt="Image" style="width: 100px;">` : ''}
<p><strong>Timestamp:</strong> ${timestamp}</p>
</div>
`;
L.marker([lat, lng]).addTo(map).bindPopup(popupContent);
}
});
})
.catch(error => console.error('Error fetching data:', error));
// Adding search geocoding
var geocoder = L.Control.geocoder().addTo(map);
// Adding current location tracking
map.locate({setView: true, maxZoom: 16, watch: true, timeout: 5000});
// function
function onLocationFound(e) {
var radius = e.accuracy;
L.marker(e.latlng).addTo(map)
.bindPopup("You are within " + radius + " meters from this point").openPopup();
}
map.on('locationfound', onLocationFound);
function onLocationError(e) {
alert(e.message);
}
map.on('locationerror', onLocationError);
// Add routing control
var routingControl = L.Routing.control({
waypoints: [
L.latLng(17.3850, 78.4867) ,
L.latLng(17.3850, 78.4867) // Destination example (Hyderabad)
],
routeWhileDragging: true,
geocoder: L.Control.Geocoder.nominatim(),
geocoder: L.Control.Geocoder.nominatim()
}).addTo(map);
// Add custom markers for start and finish with draggable option
// Add "My Location" button
L.Control.myLocation = L.Control.extend({
options: {
position: 'topright',
title: 'Show My Location'
},
onAdd: function (map) {
var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control leaflet-control-custom');
container.title = this.options.title;
container.style.backgroundColor = 'white';
container.style.width = '30px';
container.style.height = '30px';
container.style.lineHeight = '30px';
container.style.textAlign = 'center';
container.style.fontSize = '18px';
container.style.cursor = 'pointer';
container.innerHTML = '🔍'; // Icon for the button
container.onclick = function () {
map.locate({setView: true, maxZoom: 16});
};
return container;
}
});
L.control.myLocation = function (opts) {
return new L.Control.myLocation(opts);
};
L.control.myLocation().addTo(map);
//creating a mark or pin to map
var marker = null; // To keep track of the marker
// Define the custom control
L.Control.Reload = L.Control.extend({
options: {
position: 'bottomleft'
},
onAdd: function (map) {
var controlDiv = L.DomUtil.create('div', 'leaflet-control-reload');
controlDiv.innerHTML = 'Reload ';
L.DomEvent.on(controlDiv, 'click', function () {
location.reload();
});
return controlDiv;
}
});
// Add the custom control to the map
L.control.reload = function (opts) {
return new L.Control.Reload(opts);
};
L.control.reload({ position: 'bottomleft' }).addTo(map);
</script>
</body>
</html>