-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
612 lines (595 loc) · 23.5 KB
/
Copy pathindex.html
File metadata and controls
612 lines (595 loc) · 23.5 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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
<!DOCTYPE html>
<html>
<head>
<title>Goa Cadastral Data Explorer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="tokml.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="config.js"></script>
<script>
(function() {
const apiKey = window.GOOGLE_MAPS_API_KEY || 'YOUR_API_KEY_HERE';
if (apiKey === 'YOUR_API_KEY_HERE') {
console.warn('Please set your Google Maps API key in config.js (see config.example.js for template)');
}
const script = document.createElement('script');
script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=geometry&callback=initGoogleMaps`;
script.async = true;
script.defer = true;
document.head.appendChild(script);
window.initGoogleMaps = function() {
console.log('Google Maps API loaded');
window.googleMapsLoaded = true;
window.dispatchEvent(new Event('googlemapsloaded'));
};
})();
</script>
<style>
body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #fff; }
#app {
background: #fff;
padding: 16px;
margin: 0;
min-height: 100vh;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
h1, h3 { color: #333; margin-top: 0; }
.header-row {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 2px solid #e0e0e0;
}
.toolbar {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
}
.export-dropdown { position: relative; display: inline-block; }
#export-button {
padding: 10px 18px;
background: #28a745;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
}
#export-button:disabled { background: #ccc; cursor: not-allowed; }
#export-button:not(:disabled):hover { background: #218838; }
.dropdown-content {
display: none;
position: absolute;
left: 0;
top: 100%;
background-color: #f9f9f9;
min-width: 220px;
box-shadow: 0 8px 16px rgba(0,0,0,0.15);
z-index: 20;
border-radius: 4px;
overflow: hidden;
}
.dropdown-content button {
display: block;
width: 100%;
text-align: left;
padding: 12px 16px;
border: none;
background: white;
cursor: pointer;
font-size: 14px;
}
.dropdown-content button:hover { background: #f1f1f1; }
.export-dropdown:hover .dropdown-content { display: block; }
.btn-secondary {
padding: 10px 16px;
font-size: 14px;
background: #343a40;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
.btn-secondary:hover:not(:disabled) { background: #23272b; }
.btn-secondary:disabled { background: #ccc; cursor: not-allowed; }
.btn-danger {
padding: 10px 16px;
font-size: 14px;
background: #dc3545;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
.btn-danger:hover:not(:disabled) { background: #c82333; }
.btn-danger:disabled { background: #ccc; cursor: not-allowed; }
.info-box {
background: #e7f3ff;
border-left: 4px solid #007bff;
padding: 12px 16px;
margin-bottom: 16px;
border-radius: 4px;
font-size: 14px;
line-height: 1.55;
color: #333;
}
.input-section {
background: #f8f9fa;
padding: 16px;
border-radius: 8px;
margin-bottom: 16px;
}
.input-section h3 { margin-top: 0; }
.input-section p { margin: 6px 0 12px 0; font-size: 14px; color: #555; }
.bulk-search-controls {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
}
#csv-upload { flex-grow: 1; min-width: 160px; }
#process-csv {
padding: 10px 16px;
background: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
#process-csv:disabled { background: #ccc; cursor: not-allowed; }
#download-template {
padding: 10px 16px;
background: transparent;
color: #6c757d;
border: 1px solid #6c757d;
border-radius: 4px;
cursor: pointer;
}
#download-template:hover { background: #6c757d; color: white; }
#csv-status { font-size: 12px; margin-top: 8px; }
.or-divider {
display: flex;
align-items: center;
margin: 16px 0;
gap: 12px;
}
.or-divider::before, .or-divider::after {
content: '';
flex: 1;
height: 1px;
background: #dee2e6;
}
.or-divider span { color: #6c757d; font-weight: 500; font-size: 14px; }
.controls {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: stretch;
}
.controls select, .controls button {
padding: 10px;
font-size: 14px;
border-radius: 4px;
border: 1px solid #ccc;
flex: 1 1 180px;
}
.controls button#add-plot-button {
background: #007bff;
color: white;
border: none;
cursor: pointer;
flex: 1 1 200px;
}
.controls button#add-plot-button:disabled {
background: #ccc;
cursor: not-allowed;
}
#loading { display: none; padding: 12px; text-align: center; color: #666; }
.main-layout {
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
}
.view-toggle-bar {
display: flex;
border-bottom: 2px solid #dee2e6;
margin-bottom: 0;
}
.view-tab {
padding: 10px 28px;
font-size: 14px;
font-weight: 600;
background: transparent;
border: none;
border-bottom: 3px solid transparent;
cursor: pointer;
color: #666;
margin-bottom: -2px;
transition: color 0.15s, border-color 0.15s;
}
.view-tab:hover { color: #333; }
.view-tab.active { color: #007bff; border-bottom-color: #007bff; }
.tab-badge {
display: inline-block;
background: #007bff;
color: #fff;
font-size: 11px;
font-weight: 700;
border-radius: 10px;
padding: 1px 7px;
margin-left: 6px;
vertical-align: middle;
}
.view-tab:not(.active) .tab-badge { background: #adb5bd; }
#map-view-panel { display: flex; flex-direction: column; }
#map {
width: 100%;
height: 100vh;
}
#table-view-panel {
padding: 12px 0;
}
#table-empty-state {
padding: 48px;
text-align: center;
color: #999;
font-size: 15px;
}
.table-container {
max-height: calc(100vh - 120px);
overflow: auto;
}
.table-container table { width: 100%; border-collapse: collapse; margin: 0; }
.table-container thead th {
position: sticky;
top: 0;
background: #f8f9fa;
border-bottom: 2px solid #dee2e6;
padding: 10px 8px;
text-align: left;
font-weight: bold;
color: #495057;
font-size: 13px;
}
.table-container tbody td {
padding: 10px 8px;
border-bottom: 1px solid #dee2e6;
vertical-align: top;
font-size: 13px;
}
.table-container tbody tr:hover { background: #f5f5f5; }
.table-container tbody tr.clickable-row { cursor: pointer; }
.property-list { font-size: 12px; max-width: 320px; }
.property-item { display: flex; gap: 5px; margin-bottom: 5px; align-items: center; flex-wrap: wrap; }
.property-item input {
padding: 4px 6px;
border: 1px solid #ccc;
border-radius: 3px;
font-size: 12px;
}
.property-item button {
padding: 2px 6px;
background: #dc3545;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
font-size: 11px;
}
.add-property-btn {
padding: 4px 8px;
background: #28a745;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
font-size: 11px;
margin-top: 4px;
}
.remove-plot-btn {
padding: 6px 10px;
background: #dc3545;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
}
/* Kebab trigger */
.kebab-btn {
background: none;
border: none;
cursor: pointer;
font-size: 22px;
line-height: 1;
padding: 2px 8px;
color: #555;
border-radius: 4px;
font-weight: 700;
letter-spacing: -1px;
}
.kebab-btn:hover { background: #f0f0f0; color: #111; }
/* Actions modal */
#action-modal-backdrop {
display: none;
position: fixed;
inset: 0;
background: rgba(0,0,0,0.38);
z-index: 2000;
align-items: center;
justify-content: center;
}
#action-modal-backdrop.open { display: flex; }
#action-modal {
background: #fff;
border-radius: 12px;
box-shadow: 0 12px 40px rgba(0,0,0,0.22);
min-width: 260px;
max-width: 340px;
width: 92%;
overflow: hidden;
animation: modalIn 0.15s ease;
}
@keyframes modalIn {
from { opacity: 0; transform: scale(0.95) translateY(-8px); }
to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 13px 16px;
border-bottom: 1px solid #dee2e6;
background: #f8f9fa;
}
.modal-title { font-weight: 700; font-size: 14px; color: #333; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close-btn {
background: none;
border: none;
font-size: 22px;
line-height: 1;
cursor: pointer;
color: #888;
padding: 0 2px;
margin-left: 8px;
flex-shrink: 0;
}
.modal-close-btn:hover { color: #333; }
.modal-body { padding: 6px 0; }
.modal-action-btn {
display: flex;
align-items: center;
gap: 12px;
padding: 11px 16px;
cursor: pointer;
font-size: 14px;
color: #222;
border: none;
background: none;
width: 100%;
text-align: left;
}
.modal-action-btn:hover { background: #f5f5f5; }
.modal-action-btn.danger { color: #dc3545; }
.modal-action-btn.danger:hover { background: #fff5f5; }
.modal-action-icon { width: 22px; text-align: center; font-size: 15px; flex-shrink: 0; }
.modal-color-row {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 16px;
font-size: 14px;
color: #222;
}
.modal-color-row input[type=color] {
width: 38px; height: 30px; padding: 0;
border: 1px solid #ccc; border-radius: 4px; cursor: pointer;
}
.modal-divider { height: 1px; background: #dee2e6; margin: 4px 0; }
.missing-geojson { background-color: #fff3cd !important; border-left: 4px solid #ffc107; }
.warning-indicator { color: #ff9800; font-weight: bold; font-size: 11px; margin-top: 4px; }
.actions-cell { max-width: 480px; }
.actions-cell .action-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.actions-cell button.mini {
padding: 5px 10px;
font-size: 11px;
border: none;
border-radius: 4px;
cursor: pointer;
color: #fff;
}
@media (max-width: 768px) {
#map { height: 100svh; }
.table-container { max-height: calc(100svh - 120px); }
.controls select, .controls button { width: 100%; box-sizing: border-box; flex: 1 1 100%; }
.bulk-search-controls { flex-direction: column; align-items: stretch; }
}
</style>
</head>
<body>
<div id="app">
<div class="header-row">
<h1 style="margin:0;">Goa Cadastral Data Explorer</h1>
<div class="toolbar">
<div class="export-dropdown">
<button type="button" id="export-button" disabled>Export layer</button>
<div class="dropdown-content">
<button type="button" onclick="window.cadastralApp.exportGeoJSON()">GeoJSON (one file)</button>
<button type="button" onclick="window.cadastralApp.exportKML()">KML (one file)</button>
</div>
</div>
<button type="button" class="btn-secondary" id="download-all-zip" onclick="window.downloadAllGeometries()">ZIP: one folder per plot</button>
<button type="button" class="btn-danger" id="clear-all-btn" disabled>Clear all</button>
</div>
</div>
<div class="info-box">
Search plots with the dropdowns or upload a CSV. Each match is added to the map and the table below the map.
Use <strong>Export layer</strong> for a single GeoJSON or KML FeatureCollection including any custom properties you add in the table.
</div>
<div class="input-section">
<h3>Upload CSV</h3>
<p>
Required column: <strong>taluka</strong>, <strong>village</strong>, <strong>survey</strong>, <strong>subdiv</strong>. Combined survey/subdiv (e.g. 99/5-A) in the survey column is supported.
Any other columns are stored as custom properties. Quoted fields are supported.
</p>
<div class="bulk-search-controls">
<input type="file" id="csv-upload" accept=".csv">
<button type="button" id="process-csv" disabled>Process CSV</button>
<button type="button" id="download-template">Download template</button>
</div>
<div id="csv-status"></div>
<div class="or-divider"><span>or</span></div>
<h3>Select a plot</h3>
<p>
Choose taluka, village, and optional survey and subdiv, then add the match to the map and table.
If you pick a survey but leave subdiv empty, every subdiv for that survey is loaded.
</p>
<div class="controls">
<select id="taluka-dropdown"><option value="">Select Taluka</option></select>
<select id="village-dropdown" disabled><option value="">Select Village</option></select>
<select id="survey-dropdown" disabled><option value="">Select Survey No (Optional)</option></select>
<select id="subdiv-dropdown" disabled><option value="">Select Subdiv (Optional)</option></select>
<button type="button" id="add-plot-button" disabled>Add to map and table</button>
</div>
</div>
<div id="loading">Loading…</div>
<div class="main-layout">
<!-- View toggle tabs -->
<div class="view-toggle-bar">
<button class="view-tab active" id="tab-map" onclick="window.switchView('map')">Map</button>
<button class="view-tab" id="tab-table" onclick="window.switchView('table')">Table <span class="tab-badge" id="plot-count">0</span></button>
</div>
<!-- Map panel -->
<div id="map-view-panel">
<div id="map"></div>
</div>
<!-- Table panel -->
<div id="table-view-panel" style="display:none;">
<div id="results-section" style="display:none;">
<div class="table-container" id="results-table-container">
<table>
<thead>
<tr>
<th>Taluka</th>
<th>Village</th>
<th>Survey</th>
<th>Subdiv</th>
<th>Properties</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="results-table-body"></tbody>
</table>
</div>
</div>
<div id="table-empty-state">No plots added yet — search above and add plots to see them here.</div>
</div>
</div>
</div>
<!-- Actions modal -->
<div id="action-modal-backdrop" onclick="window.closeActionsModal()">
<div id="action-modal" onclick="event.stopPropagation()">
<div class="modal-header">
<span class="modal-title" id="action-modal-title">Actions</span>
<button class="modal-close-btn" onclick="window.closeActionsModal()" title="Close">×</button>
</div>
<div class="modal-body" id="action-modal-body"></div>
</div>
</div>
<script>
window.switchView = function(view) {
const mapPanel = document.getElementById('map-view-panel');
const tablePanel = document.getElementById('table-view-panel');
const tabMap = document.getElementById('tab-map');
const tabTable = document.getElementById('tab-table');
if (view === 'map') {
mapPanel.style.display = '';
tablePanel.style.display = 'none';
tabMap.classList.add('active');
tabTable.classList.remove('active');
// Trigger Google Maps resize so tiles render correctly
if (window.cadastralApp && window.cadastralApp.map) {
google.maps.event.trigger(window.cadastralApp.map, 'resize');
}
} else {
mapPanel.style.display = 'none';
tablePanel.style.display = '';
tabMap.classList.remove('active');
tabTable.classList.add('active');
// Show/hide empty state
const hasResults = document.getElementById('results-section').style.display !== 'none';
document.getElementById('table-empty-state').style.display = hasResults ? 'none' : '';
}
};
window.openActionsModal = function(plotId) {
const app = window.cadastralApp;
const feature = app && app.features.find(f => f.properties._plotId === plotId);
if (!feature) return;
const props = feature.properties;
const hasGeom = !!(feature.geometry && feature.geometry.coordinates);
const colorVal = props._polygonColor || '#007cba';
// Title: village + survey/subdiv
const surveyLabel = props.survey ? props.survey + (props.subdiv ? '/' + props.subdiv : '') : 'All surveys';
document.getElementById('action-modal-title').textContent = props.village + ' \u2013 ' + surveyLabel;
let html = '';
if (hasGeom) {
html += `<div class="modal-color-row">
<span class="modal-action-icon">●</span>
<span style="flex:1;">Polygon color</span>
<input type="color" value="${colorVal}"
onchange="window.cadastralApp.changePolygonColor('${plotId}', this.value)"
onclick="event.stopPropagation();">
</div>
<div class="modal-divider"></div>
<button class="modal-action-btn" onclick="copyKML('${plotId}');window.closeActionsModal()">
<span class="modal-action-icon">📄</span>Download KML
</button>
<button class="modal-action-btn" id="modal-copy-geojson-btn"
onclick="window._modalCopyGeoJSON('${plotId}')">
<span class="modal-action-icon">📋</span>Copy GeoJSON
</button>
<button class="modal-action-btn" onclick="openAmcheLink('${plotId}');window.closeActionsModal()">
<span class="modal-action-icon">🔗</span>Open Amche link
</button>
<div class="modal-divider"></div>`;
}
html += `<button class="modal-action-btn danger" onclick="window.cadastralApp.removePlot('${plotId}');window.closeActionsModal()">
<span class="modal-action-icon">🗑</span>Remove plot
</button>`;
document.getElementById('action-modal-body').innerHTML = html;
document.getElementById('action-modal-backdrop').classList.add('open');
};
window._modalCopyGeoJSON = function(plotId) {
const btn = document.getElementById('modal-copy-geojson-btn');
const labelSpan = btn ? btn.querySelector('span:last-child') : null;
let _txt = labelSpan ? labelSpan.textContent : 'Copy GeoJSON';
window.copyGeoJSON(plotId, {
get textContent() { return _txt; },
set textContent(v) {
_txt = v;
if (labelSpan) labelSpan.textContent = v || 'Copy GeoJSON';
if (v === 'Copied!') setTimeout(() => window.closeActionsModal(), 1200);
}
});
};
window.closeActionsModal = function() {
document.getElementById('action-modal-backdrop').classList.remove('open');
};
// Close modal on Escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') window.closeActionsModal();
});
</script>
<script type="module" src="app.js"></script>
</body>
</html>