-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
349 lines (317 loc) · 13.3 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
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
<!DOCTYPE html>
<html>
<head>
<title>Area</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
#map {
height: 100%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#floating-panel {
position: absolute;
top: 10px;
left: 25%;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
text-align: center;
font-family: 'Roboto','sans-serif';
line-height: 30px;
padding-left: 10px;
}
img[src="https://vjyanand.github.io/big.png"] {
transform: rotate(20deg);
}
</style>
</head>
<body>
<div id="map"></div>
<div id="floating-panel">
<input type="text" readonly id="sqm">
<input type="text" readonly id="acre">
<button id="edit" onClick='toggleEditMode(this)'>Edit</button>
<input id="r-opacity" type="range" min="0" max="1" step="0.05" value="0">
</div>
<script>
var infoWindow;
var conversionFactor = 0.000247105
var polygonsamySmallBit, polygonsamyKadu, polygonroadSide, polygonroadEntrance, polygonbigBit, polygonmurugeshLong, polygonpudharKadu;
var editMode = false;
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 18,
mapTypeId: google.maps.MapTypeId.SATELLITE,
mapTypeControl: false,
streetViewControl: false,
stylers: [{
visibility: 'off'
}],
featureType: 'poi',
center: {
lat: 11.253142,
lng: 78.322260
}
});
var bigBit = [
new google.maps.LatLng(11.251949, 78.322311),
new google.maps.LatLng(11.251806, 78.322753),
new google.maps.LatLng(11.252049, 78.322860),
new google.maps.LatLng(11.252249, 78.322790),
new google.maps.LatLng(11.252488, 78.322840),
new google.maps.LatLng(11.252608, 78.322832),
new google.maps.LatLng(11.252735, 78.322830),
new google.maps.LatLng(11.252841, 78.323107),
new google.maps.LatLng(11.252919, 78.323122),
new google.maps.LatLng(11.252999, 78.323122),
new google.maps.LatLng(11.253035, 78.323256),
new google.maps.LatLng(11.253142, 78.323310),
new google.maps.LatLng(11.2532166392, 78.3231166285),
new google.maps.LatLng(11.253216, 78.323120),
new google.maps.LatLng(11.253228, 78.323108),
new google.maps.LatLng(11.253229, 78.323109),
new google.maps.LatLng(11.253228, 78.323113),
new google.maps.LatLng(11.253399, 78.323118),
new google.maps.LatLng(11.253401, 78.323119),
new google.maps.LatLng(11.253663, 78.323144),
new google.maps.LatLng(11.253649, 78.322991),
new google.maps.LatLng(11.253646, 78.323002),
new google.maps.LatLng(11.253646, 78.323002),
new google.maps.LatLng(11.253666, 78.322806),
new google.maps.LatLng(11.253661, 78.322804),
new google.maps.LatLng(11.254365, 78.322819),
new google.maps.LatLng(11.254363, 78.322895),
new google.maps.LatLng(11.254414, 78.322949),
new google.maps.LatLng(11.254659, 78.322861),
new google.maps.LatLng(11.254813, 78.322895),
new google.maps.LatLng(11.254755, 78.323014),
new google.maps.LatLng(11.254575, 78.323111),
new google.maps.LatLng(11.254509, 78.323187),
new google.maps.LatLng(11.254392, 78.323255),
new google.maps.LatLng(11.254307, 78.323301),
new google.maps.LatLng(11.254240, 78.323282),
new google.maps.LatLng(11.254167, 78.323566),
new google.maps.LatLng(11.254158, 78.323574),
new google.maps.LatLng(11.254341, 78.323612),
new google.maps.LatLng(11.254517, 78.323607),
new google.maps.LatLng(11.254752, 78.323382),
new google.maps.LatLng(11.254918, 78.323150),
new google.maps.LatLng(11.255024, 78.323058),
new google.maps.LatLng(11.255149, 78.323035),
new google.maps.LatLng(11.255318, 78.322907),
new google.maps.LatLng(11.255318, 78.322775),
new google.maps.LatLng(11.255361, 78.322680),
new google.maps.LatLng(11.255309, 78.322586),
new google.maps.LatLng(11.255296, 78.322409),
new google.maps.LatLng(11.255294, 78.322337),
new google.maps.LatLng(11.255256, 78.322265),
new google.maps.LatLng(11.255135, 78.322239),
new google.maps.LatLng(11.255110, 78.322287),
new google.maps.LatLng(11.255022, 78.322418),
new google.maps.LatLng(11.254961, 78.322466),
new google.maps.LatLng(11.254861, 78.322554),
new google.maps.LatLng(11.254822, 78.322605),
new google.maps.LatLng(11.254782, 78.322636),
new google.maps.LatLng(11.254656, 78.322691),
new google.maps.LatLng(11.254608, 78.322635),
new google.maps.LatLng(11.254534, 78.322635),
new google.maps.LatLng(11.254390, 78.322665),
new google.maps.LatLng(11.254230, 78.322625),
new google.maps.LatLng(11.254057, 78.322572),
new google.maps.LatLng(11.253993, 78.322508),
new google.maps.LatLng(11.253866, 78.322472),
new google.maps.LatLng(11.253842, 78.322313),
new google.maps.LatLng(11.253719, 78.322335),
new google.maps.LatLng(11.253636, 78.322412),
new google.maps.LatLng(11.253231, 78.322345),
new google.maps.LatLng(11.253228, 78.322193),
new google.maps.LatLng(11.253046, 78.322202),
new google.maps.LatLng(11.252844, 78.322199),
new google.maps.LatLng(11.252555, 78.322210),
new google.maps.LatLng(11.252400, 78.322281),
new google.maps.LatLng(11.252339, 78.322368),
new google.maps.LatLng(11.252123, 78.322315),
]
var samyKadu = [
new google.maps.LatLng(11.254873, 78.322146),
new google.maps.LatLng(11.254920, 78.322015),
new google.maps.LatLng(11.254976, 78.322027),
new google.maps.LatLng(11.254988, 78.321932),
new google.maps.LatLng(11.254863, 78.321863),
new google.maps.LatLng(11.254819, 78.321811),
new google.maps.LatLng(11.254884, 78.321542),
new google.maps.LatLng(11.255067, 78.321162),
new google.maps.LatLng(11.255102, 78.321105),
new google.maps.LatLng(11.255027, 78.321075),
new google.maps.LatLng(11.254852, 78.321264),
new google.maps.LatLng(11.254810, 78.321491),
new google.maps.LatLng(11.254636, 78.321477),
new google.maps.LatLng(11.254605, 78.321836),
new google.maps.LatLng(11.254703, 78.321806),
new google.maps.LatLng(11.254802, 78.322102),
]
var vakilKadu = [
new google.maps.LatLng(11.2550421,78.3220766),
new google.maps.LatLng(11.2552433,78.3220886),
new google.maps.LatLng(11.2552242,78.3219529),
new google.maps.LatLng(11.2552245,78.3218251),
new google.maps.LatLng(11.255256,78.3217315),
new google.maps.LatLng(11.2550389,78.3216244),
new google.maps.LatLng(11.2550673,78.3215458),
new google.maps.LatLng(11.2549211,78.3214554),
new google.maps.LatLng(11.2548325,78.3218314),
new google.maps.LatLng(11.254918,78.3219347),
new google.maps.LatLng(11.2549883,78.3218495),
new google.maps.LatLng(11.255033,78.3219219),
new google.maps.LatLng(11.2550222,78.3220078),
]
var pudharKadu = [
new google.maps.LatLng(11.2536624,78.3234488),
new google.maps.LatLng(11.2537014,78.3232678),
new google.maps.LatLng(11.2538384,78.3233328),
new google.maps.LatLng(11.2537994,78.3234858),
]
var samySmallBit = [
new google.maps.LatLng(11.254876, 78.320731),
new google.maps.LatLng(11.255032, 78.320738),
new google.maps.LatLng(11.255118, 78.320595),
new google.maps.LatLng(11.255119, 78.320583),
new google.maps.LatLng(11.255098, 78.320552),
new google.maps.LatLng(11.255057, 78.320538),
new google.maps.LatLng(11.254980, 78.320582),
]
var roadSide = [
new google.maps.LatLng(11.254385, 78.320705),
new google.maps.LatLng(11.254461, 78.320728),
new google.maps.LatLng(11.254385, 78.320980),
new google.maps.LatLng(11.254309, 78.321002),
]
var roadEntrance = [
new google.maps.LatLng(11.253540, 78.321295),
new google.maps.LatLng(11.253408, 78.321338),
new google.maps.LatLng(11.253467, 78.321524),
new google.maps.LatLng(11.253602, 78.321529),
]
var murugeshLong = [
new google.maps.LatLng(11.253326, 78.321765),
new google.maps.LatLng(11.253352, 78.321991),
new google.maps.LatLng(11.2537914, 78.321976),
new google.maps.LatLng(11.253735, 78.3217119),
]
polygonmurugeshLong = new google.maps.Polygon({
path: murugeshLong,
strokeColor: '#FF0000',
strokeWeight: 0.50,
map: map
})
polygonbigBit = new google.maps.Polygon({
path: bigBit,
strokeColor: '#FFF000',
strokeWeight: 0.50,
map: map
})
polygonroadEntrance = new google.maps.Polygon({
path: roadEntrance,
strokeColor: '#3361e0',
strokeWeight: 0.50,
map: map
})
polygonroadSide = new google.maps.Polygon({
path: roadSide,
strokeColor: '#FF00F0',
strokeWeight: 0.50,
map: map
})
polygonsamyKadu = new google.maps.Polygon({
path: samyKadu,
strokeColor: '#FF4070',
strokeWeight: 0.50,
map: map
})
polygonsamySmallBit = new google.maps.Polygon({
path: samySmallBit,
strokeColor: '#0FA090',
strokeWeight: 0.50,
map: map
})
polygonpudharKadu = new google.maps.Polygon({
path: pudharKadu,
strokeColor: '#4FE010',
strokeWeight: 0.50,
map: map
})
polygonVakilKadu = new google.maps.Polygon({
path: vakilKadu,
strokeColor: '#03fcb5',
strokeWeight: 0.50,
map: map
})
polygonsamySmallBit.addListener('click', showDetails);
polygonsamyKadu.addListener('click', showDetails);
polygonroadSide.addListener('click', showDetails);
polygonroadEntrance.addListener('click', showDetails);
polygonbigBit.addListener('click', showDetails);
polygonmurugeshLong.addListener('click', showDetails);
polygonpudharKadu.addListener('click', showDetails);
polygonVakilKadu.addListener('click', showDetails);
infoWindow = new google.maps.InfoWindow;
calculateArea()
}
function addOverlay(map) {
//point1(11.251412035321865, 78.32108132934582)
//point2(11.255606264452348, 78.32395227622987)
var swBound = new google.maps.LatLng(11.251412035321865, 78.32108132934582);
var neBound = new google.maps.LatLng(11.255606264452348, 78.32395227622987);
var imageBounds = new google.maps.LatLngBounds(swBound, neBound);
var imageMapOverlay = new google.maps.GroundOverlay('https://vjyanand.github.io/big.png', imageBounds);
imageMapOverlay.setMap(map);
var p = document.getElementById("r-opacity");
p.addEventListener("input", function() {
imageMapOverlay.setOpacity(parseFloat(p.value));
}, false);
}
function toggleEditMode(source) {
editMode = !editMode
source.innerText = (editMode) ? 'Calculate' : 'Edit';
polygonsamySmallBit.setEditable(editMode)
polygonsamyKadu.setEditable(editMode)
polygonroadSide.setEditable(editMode)
polygonroadEntrance.setEditable(editMode)
polygonbigBit.setEditable(editMode)
polygonmurugeshLong.setEditable(editMode)
polygonpudharKadu.setEditable(editMode)
polygonVakilKadu.setEditable(editMode)
calculateArea();
}
function calculateArea() {
var areasamySmallBit = google.maps.geometry.spherical.computeArea(polygonsamySmallBit.getPath())
var areasamyKadu = google.maps.geometry.spherical.computeArea(polygonsamyKadu.getPath())
var arearoadSide = google.maps.geometry.spherical.computeArea(polygonroadSide.getPath())
var arearoadEntrance = google.maps.geometry.spherical.computeArea(polygonroadEntrance.getPath())
var areabigBit = google.maps.geometry.spherical.computeArea(polygonbigBit.getPath())
var areamurugeshLong = google.maps.geometry.spherical.computeArea(polygonmurugeshLong.getPath())
var areapudharKadu = google.maps.geometry.spherical.computeArea(polygonpudharKadu.getPath())
var totalAreaSquareMeters = (areasamySmallBit + areasamyKadu + arearoadSide + arearoadEntrance + areabigBit + areamurugeshLong + areapudharKadu)
var totalAreaAcres = totalAreaSquareMeters * conversionFactor
document.getElementById('sqm').value = totalAreaSquareMeters.toFixed(3) + ' ㎡';
document.getElementById('acre').value = totalAreaAcres.toFixed(3) + ' Acres' ;
}
function showDetails(event) {
var vertices = this.getPath();
var area = google.maps.geometry.spherical.computeArea(vertices);
var areaAcres = area * conversionFactor
var contentString = '<b>Area:</b><br>' + area.toFixed(3) + "㎡, " + areaAcres.toFixed(3)
infoWindow.setContent(contentString);
infoWindow.setPosition(event.latLng);
infoWindow.open(this.map);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCQ1gos8OiUEi9NgJ3fti8_rqesRV8Lujc&libraries=geometry&callback=initMap" async defer></script>
</body>
</html>