-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCambrilsCellsv3.html
674 lines (560 loc) · 27.3 KB
/
CambrilsCellsv3.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
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
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Cambrils Cells</title>
<!-- title>Vilafranca del Penedes Cells</title -->
<!-- title>Hospitalet Miami Montroig Cells</title -->
<!-- title>Masnou Teia Alella Cells</title -->
<link rel="apple-touch-icon" href="./icons/pokestop_top.png">
<link rel="shortcut icon" href="./icons/pokestop_top.png">
<link rel="icon" type="image/png" href="./icons/pokestop_top.png" sizes="192x192">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#fafafa" />
<!-- S2 GEOMETRY -->
<script src="https://unpkg.com/s2-geometry" crossorigin></script>
<!-- script src="https://unpkg.com/s2-geometry@1.2.9/src/s2geometry.js"
integrity="sha384-WGDofm6Km+bZIxd/uBU2QJlwIMxX/9H5H7G9glfYtcAAR8vrm0wbzvtpIG54XhOZ"
crossorigin=""></script -->
<!-- LEAFLET -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@latest/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@latest/dist/leaflet.js"></script>
<!-- link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
-->
<!-- script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
></script -->
<!-- LEAFLET HASH -->
<script src="https://unpkg.com/leaflet-hash" crossorigin></script>
<!-- LEAFLET PANEL LAYERS -->
<!-- link rel="stylesheet" href="./leaflet panel layers/leaflet-panel-layers.css" / -->
<!-- script src="./leaflet panel layers/leaflet-panel-layers.js"></script -->
<!-- LEAFLET SEARCH -->
<link rel="stylesheet" href="https://unpkg.com/leaflet-search/dist/leaflet-search.src.css" crossorigin />
<script src="https://unpkg.com/leaflet-search/dist/leaflet-search.src.js" crossorigin ></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link rel="stylesheet" href="./css/style.css" />
<!-- JQUERY -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<!-- TABLETOP -->
<script src='https://cdn.jsdelivr.net/npm/tabletop@1.6.2/src/tabletop.min.js'></script>
<!-- LEAFLET EXTRA MARKERS -->
<script src="https://cdn.jsdelivr.net/npm/leaflet-extra-markers@1.0.6/src/assets/js/leaflet.extra-markers.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet-extra-markers@1.0.6/dist/css/leaflet.extra-markers.min.css">
<!-- FONT AWESOME -->
<!-- link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" -->
<!-- LEAFLET CONTROL LOCATE -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet.locatecontrol/dist/L.Control.Locate.min.css" />
<script src="https://cdn.jsdelivr.net/npm/leaflet.locatecontrol/dist/L.Control.Locate.min.js" charset="utf-8"></script>
<!-- LEAFLET POLILINEMEASURE -->
<link rel="stylesheet" href="https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.css" />
<script src="https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.js"></script>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body,
main {
height: 100%;
weight: 100%;
}
.NumeroCoSi {font-size: 36px; text-align: center; color: red} // Tamaño y color numero faltan para gyms
.AlineaCenter { text-align: center }
.circleimg { width: 20px; height: 20px; border-radius: 50%; margin-top: 8px; }
</style>
</head>
<body>
<main id="map"></main>
<script>
///////////////////////////////////////////////////////////////////
// Setup the Leaflet map (declaracion variables y constantes)
let ZoomMax = 20 ; // Zoom Maximo
let ZoomVis = 4 ; // A partir de que zoom se empieza ver mapa satelite (ZoomMax - ZoomVis)
// Grupos de marcadores
var LG_gym = new L.LayerGroup(); // Grupo gimnasios
var LG_pokestop = new L.LayerGroup(); // Grupo Pokeparadas
var LG_gymex = new L.LayerGroup(); // Grupo Gimnasios EX
var LG_propuestas = new L.LayerGroup(); // Grupo Pedidas
var LG_aceptadas = new L.LayerGroup(); // Grupo Aceptadas
var LG_sugerencias = new L.LayerGroup(); // Grupo Sugerencias
var LG_ContadorPG = new L.LayerGroup(); // Grupo Contador Pokeparadas y Gimnasios celda 14
var LG_Circle20m = new L.LayerGroup(); // Grupo Area 20 metros pokeparadas y gimnasios
var LG_Ingress = new L.LayerGroup(); // Grupo portales ingress con su area 20 metros
var LG_FaltanGym = new L.LayerGroup(); // Grupo numero pokeparadas faltal para que salte gimnasio.
var LG_Celda17Fill = new L.LayerGroup(); // Grupo sombreado de celdas 17 ocupadas.
const map = L.map('map', {
maxZoom: ZoomMax,
zoom: (ZoomMax/2),
animate: true,
layers: [LG_gym, LG_pokestop, LG_gymex,]
}).locate({setView: true, enableHighAccuracy: true, }); //setView([22.57, 88.32403643149632], 15)
//map.fitBounds([[41.104215, 0.967693],[41.057519, 1.133946]]); // Cambrils
// eslint-disable-next-line no-unused-vars
//const hash = new L.Hash(map);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The fabled Google Maps satellite layer :angelic choir:
/*
var Mcalles = L.tileLayer('http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}', {
subdomains:['mt0','mt1','mt2','mt3'] , maxZoom: 25
});
var Mhibrido = L.tileLayer('http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}', {
subdomains:['mt0','mt1','mt2','mt3'] , maxZoom: 25
});
var Msatelit = L.tileLayer('http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
subdomains:['mt0','mt1','mt2','mt3'] , maxZoom: 25
});
var Mterreno = L.tileLayer('http://{s}.google.com/vt/lyrs=p&x={x}&y={y}&z={z}', {
subdomains:['mt0','mt1','mt2','mt3'] , maxZoom: 25
});
https://stackoverflow.com/questions/29692737/customizing-google-map-tile-server-url
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Mapas calles y satellite
const tileSatellite = L.tileLayer('http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
subdomains:['mt0','mt1','mt2','mt3'] , maxZoom: ZoomMax ,
}).addTo(map);
var token = 'pk.eyJ1IjoiZG9tb3JpdHoiLCJhIjoiY2o0OHZuY3MwMGo1cTMybGM4MTFrM2dxbCJ9.yCQe43DMRqobazKewlhi9w';
var mapboxUrl = 'https://api.mapbox.com/styles/v1/mapbox/streets-v10/tiles/{z}/{x}/{y}@2x?access_token=' + token;
const tileStreet = new L.TileLayer(mapboxUrl, {tileSize: 512,zoomOffset: -1,maxZoom: ZoomMax}).addTo(map);
//const tileStreet = L.tileLayer('https://mts0.google.com/vt/lyrs=m&x={x}&y={y}&z={z}&apistyle=s.t%3A33|s.e%3Al|p.v%3Aoff', {
// subdomains:['mt0','mt1','mt2','mt3'] , maxZoom: ZoomMax ,
//}).addTo(map);
///////////////////////////////////////////////////////////////////
// Controles
L.control.locate({
flyTo: true,
drawCircle: true,
drawMarker: true,
enableHighAccuracy:true
}).addTo(map);
L.control.polylineMeasure({
// position: 'topright',
// showClearControl: true, // Show a control to clear all the measurements
}).addTo(map);
L.control.scale().addTo(map);
var overlayMaps =
{
// "Gym": LG_gym,
// "Pokeparada": LG_pokestop,
// "Gym EX": LG_gymex,
// "Pedidas": LG_propuestas,
// "Sugerencias": LG_sugerencias,
// "Aceptadas": LG_aceptadas,
// "Total Po GY" : LG_ContadorPG,
// "20 Metros" : LG_Circle20m,
// "Ingress Portal" : LG_Ingress,
};
ControlLayer=L.control.layers(null, overlayMaps).addTo(map);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Visusalizacion de mapa segun zoom
const updateTiles = () => {
const zoom = map.getZoom();
if (zoom >(ZoomMax- ZoomVis)) {
tileStreet.setOpacity(1 - (zoom - (ZoomMax-ZoomVis)) / ZoomVis) ;
tileSatellite.setOpacity(0 + (zoom - (ZoomMax-ZoomVis)) /ZoomVis);
}
else
{
tileStreet.setOpacity(1);
tileSatellite.setOpacity(0);
};
};
map.on('zoomend', updateTiles);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ICONOS
let ipokestop = L.ExtraMarkers.icon ({
icon: "fa-chrome", //"fa-dice-d6",
markerColor: "cyan" , shape: "circle" , prefix: "fab" , //innerHTML:'<img class="circleimg" src="./icons/black pokestop.png">' ,
}); // Icono Pokeparada
let ipropuesta = L.ExtraMarkers.icon ({
// icon: "fa-tools",markerColor: "orange",shape: "square", prefix: "fas"
// icon: 'fa-spinner',
icon: 'fa-tools',
iconSize: '[48,64]',
shape: 'square',
markerColor: 'violet',
prefix: 'fa',
extraClasses: 'fa-spin'
}); // Icono Propuesta
let igym = L.ExtraMarkers.icon ({
icon: "fa-egg" , markerColor: "yellow" , shape: "penta" , prefix: "fas" ,
}); // Icono Gimnasio
let igymex = L.ExtraMarkers.icon ({
icon: "fa-splotch" , markerColor: "yellow" , shape: "star" , prefix: "fas" , extraClasses: 'fa-pulse' ,
}); // Icono Gim ex
let iaceptada = L.ExtraMarkers.icon ({
icon: "fa-thumbs-up" , markerColor: "green-light" , shape: "circle" , prefix: "fas" ,
}); // Icono aceptada
let isugerencia = L.ExtraMarkers.icon ({
icon: "fa-question" , markerColor: "black" , shape: "circle" , prefix: "fas" ,
}); // Icono sugerencia
let iIngress = L.ExtraMarkers.icon ({
icon: "fa-dice-d20",markerColor: "green-dark",shape: "circle", prefix: "fas" , innerHTML:'<img class="circleimg" src="./icons/ingress.png">' ,
}); // Icono Ingress Portal
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Cargar pokeparadas y gyms
var MarkerCirclerOptions = // Marker Circulo de 20 metros
{
radius: 20,
fillColor: "#ff0000",
color: "#ff0000",
weight: 3,
opacity: 0.7,
fillOpacity: 0.2,
interactive: false,
clickable: false,
// bubblingMouseEvents = false,
};
var MarkerPoligonOptions = // Marker Poligono sombreado celda 17.
{
fillColor: "#000000",
color: "#000000",
weight: 1,
opacity: 0,
fillOpacity: 0.4,
interactive: false,
fill: true,
clickable: false,
noClip: true,
// bubblingMouseEvents = false,
};
var MarkerPoligonOptions14 = // Marker Poligono sombreado celda 14.
{
fillColor: "#FF0000",
color: "#FF0000",
weight: 5,
opacity: 0,
fillOpacity: 0.2,
interactive: false,
fill: true,
clickable: false,
noClip: true,
// bubblingMouseEvents = false,
};
var MarkerNumCell14 = // Para contar pokestops y gyms en celdas 14
{
Lat1 : 0, // Latitud esquina superior izquierda
Lon1 : 0, // Longitud esquina superior izquierda
Lat2 : 0, // Latitud esquina inferior derecha
Lon2 : 0, // Longitud esquina inferior derecha
ContMark : 1 // Contador de markadores misma celda
};
ArrayMarkerNumCell14 = []; // Array de celdas 14 con numero de pokeparadas y gyms
var ContMarkerNumCell14 = 0; // Contador de celdas con marcadores
// var code = "1MBo6bA7aHIf4h-I0EkhDQB2YRAH9qijjnueobVfaets" // Key code Excel datos vilafranca
// var code = "1i7XMmyJ3maDAGr8PdeNo9FzLwQc_1e_pbjy3DYepjak" // Key Code Excel Hospi Miami Montroig
// var code = "1dfnZeHb7kD660uazTuxgRH87qGXOA8Nf366n-hYMSFM" // Key Code Excel datos Mas Tei Ale
var code = "1rRcKbQqjrIVVVFO1smLvdVg-UrYrQ88ck0chL-I0Fss" // Key Code Excel datos Cambrils
Tabletop.init(
{
key: code,
callback: function(sheet, tabletop)
{
let contador = 1; // Para saber en que linea de la hoja de datos se encuentra el marcador
$.each( tabletop.sheets("pokestop").all(), function(i, pokestop) // Marcadores Pokeparadas
{
contador ++; // Para saber en que linea de la hoja de datos se encuentra el marcador
var loc = new L.latLng(pokestop.latitude, pokestop.longitude);
marker = new L.Marker(loc, {title: pokestop.nombre, icon: ipokestop} );
marker.bindPopup("<h2><b style='color: #0044ff'>" + pokestop.nombre + "<br>" + "</h2>" + pokestop.city + " (" + contador + ")" + "</b></h2>" +
" <h3><a href='http://maps.google.com/maps?q=" +pokestop.latitude+","+pokestop.longitude+ "'>" + pokestop.latitude+", "+pokestop.longitude + "</a></h3>" +
"<div id='infoboxpic'><div id='infoboxpicin'><div id='infoboxpicimg' style='background-image: url(" + pokestop.imagen + ");'></div></div></div>");
marker.addTo(LG_pokestop); // Añadimos al grupo de pokestop
new L.circle ( loc , MarkerCirclerOptions ).addTo(LG_Circle20m);
ContarPOGYC14(loc); //Contador de Pokeparadas en celda14
const cell = S2.S2Cell.FromLatLng(loc, 17);
const corners = cell.getCornerLatLngs();
new L.polyline([corners[0], corners[1], corners[2] , corners[3]], MarkerPoligonOptions).addTo(LG_Celda17Fill);
});
ControlLayer.addOverlay(LG_pokestop,"Pokeparadas (<b>"+ (contador-1) + "</b>)");
contador=0;
$.each( tabletop.sheets("gym").all(), function(i, gim) // Marcadores Gimnsasios
{
contador++;
var loc = new L.latLng(gim.latitude, gim.longitude);
marker = new L.Marker(loc, {title: gim.nombre, icon: igym} );
marker.bindPopup("<h2><b style='color: #ff8800'>" + gim.nombre + "<br>" + "</h2>" + gim.city + "</b></h2>" +
" <h3><a href='http://maps.google.com/maps?q=" +gim.latitude+","+gim.longitude+ "'>" + gim.latitude +", "+ gim.longitude + "</a></h3>" +
"<div id='infoboxpic'><div id='infoboxpicin'><div id='infoboxpicimg' style='background-image: url(" + gim.imagen + ");'></div></div></div>");
marker.addTo(LG_gym); // Añadimos al grupo de gyms
new L.circle ( loc , MarkerCirclerOptions ).addTo(LG_Circle20m);
ContarPOGYC14(loc); //Contador de Pokeparadas en celda14
const cell = S2.S2Cell.FromLatLng(loc, 17);
const corners = cell.getCornerLatLngs();
new L.polyline([corners[0], corners[1], corners[2] , corners[3]], MarkerPoligonOptions).addTo(LG_Celda17Fill);
});
ControlLayer.addOverlay(LG_gym,"Gyms (<b>"+ contador + "</b>)");
contador=0;
$.each( tabletop.sheets("gymex").all(), function(i, gymex) // Marcadores Gimnasios EX
{
contador++;
var loc = new L.latLng(gymex.latitude, gymex.longitude);
marker = new L.Marker(loc, {title: gymex.nombre, icon: igymex} );
marker.bindPopup("<h2><b style='color: #ffdd00'>" + gymex.nombre + "<br>" + "</h2>" + gymex.city + "</b></h2>" +
" <h3><a href='http://maps.google.com/maps?q=" +gymex.latitude+","+gymex.longitude+ "'>" + gymex.latitude+", "+gymex.longitude + "</a></h3>" +
"<div id='infoboxpic'><div id='infoboxpicin'><div id='infoboxpicimg' style='background-image: url(" + gymex.imagen + ");'></div></div></div>");
marker.addTo(LG_gymex); // Añadimos al grupo de gym ex
new L.circle ( loc , MarkerCirclerOptions ).addTo(LG_Circle20m);
ContarPOGYC14(loc); //Contador de Pokeparadas en celda14
const cell = S2.S2Cell.FromLatLng(loc, 17);
const corners = cell.getCornerLatLngs();
new L.polyline([corners[0], corners[1], corners[2] , corners[3]], MarkerPoligonOptions).addTo(LG_Celda17Fill);
});
ControlLayer.addOverlay(LG_gymex,"Gyms Ex (<b>"+ (contador) + "</b>)");
contador=0;
$.each( tabletop.sheets("Propuesta").all(), function(i, propuesta) // Marcadores Pedidos
{
contador++;
var loc = [propuesta.latitude, propuesta.longitude];
marker = new L.Marker(new L.latLng(loc), {title: propuesta.nombre, icon: ipropuesta} );
marker.bindPopup("<h2><b style='color: #44ff00'>" + propuesta.nombre + "<br>" + "</h2>" + propuesta.city + "</b></h2>" +
" <h3><a href='http://maps.google.com/maps?q=" +propuesta.latitude+","+propuesta.longitude+ "'>" + propuesta.latitude+", "+propuesta.longitude + "</a></h3>" +
"<div id='infoboxpic'><div id='infoboxpicin'><div id='infoboxpicimg' style='background-image: url(" + propuesta.imagen + ");'></div></div></div>");
marker.addTo(LG_propuestas); // Añadimos al grupo de pedidas
});
ControlLayer.addOverlay(LG_propuestas,"Pedidas (<b>"+ (contador) + "</b>)");
contador=0;
$.each( tabletop.sheets("Aceptadas").all(), function(i, aceptada) // Marcadores Aceptadas
{
contador++;
var loc = new L.latLng(aceptada.latitude, aceptada.longitude);
marker = new L.Marker( loc , {title: aceptada.nombre, icon: iaceptada} );
marker.bindPopup("<h2><b style='color: #0044ff'>" + aceptada.nombre + "<br>" + "</h2>" + aceptada.city + "</b></h2>" +
" <h3><a href='http://maps.google.com/maps?q=" +aceptada.latitude+","+aceptada.longitude+ "'>" + aceptada.latitude+", "+aceptada.longitude + "</a></h3>" +
"<div id='infoboxpic'><div id='infoboxpicin'><div id='infoboxpicimg' style='background-image: url(" + aceptada.imagen + ");'></div></div></div>");
marker.addTo(LG_aceptadas); // Añadimos al grupo de Aceptadas
ContarPOGYC14(loc); //Contador de Pokeparadas en celda14
});
ControlLayer.addOverlay(LG_aceptadas,"Aceptadas (<b>"+ (contador) + "</b>)");
contador = 1; // Para saber en que linea de la hoja de datos se encuentra el marcador
$.each( tabletop.sheets("Sugerencia").all(), function(i, sugerencia)
{
contador ++; // Para saber en que linea de la hoja de datos se encuentra el marcador
var loc = [sugerencia.latitude, sugerencia.longitude];
marker = new L.Marker(new L.latLng(loc), {title: sugerencia.nombre, icon: isugerencia} );
marker.bindPopup("<h2><b style='color: #444444'>" + sugerencia.nombre + "<br>" + "</h2>" + sugerencia.city + " (" + contador + ")" + "</b></h2>" +
" <h3><a href='http://maps.google.com/maps?q=" +sugerencia.latitude+","+sugerencia.longitude+ "'>" + sugerencia.latitude+", "+sugerencia.longitude + "</a></h3>" +
"<div id='infoboxpic'><div id='infoboxpicin'><div id='infoboxpicimg' style='background-image: url(" + sugerencia.imagen + ");'></div></div></div>");
marker.addTo(LG_sugerencias); // Añadimos al grupo de Sugeridas
});
ControlLayer.addOverlay(LG_sugerencias,"Sugerencias (<b>"+ (contador-1) + "</b>)");
contador = 0;
$.each( tabletop.sheets("Ingress").all(), function(i, ingress) // Marcadores Portales ingress
{
contador++;
var loc = new L.latLng(ingress.latitude, ingress.longitude);
new L.circle ( loc , MarkerCirclerOptions ).addTo(LG_Ingress); // radio 20 metros
marker = new L.Marker(loc, {title: ingress.nombre, icon: iIngress} );
marker.bindPopup("<h2><b style='color: #00AA00'>" + ingress.nombre + "<br>" + "</h2>" + ingress.city + "</b></h2>" +
" <h3><a href='http://maps.google.com/maps?q=" +ingress.latitude+","+ingress.longitude+ "'>" + ingress.latitude +", "+ ingress.longitude + "</a></h3>" +
"<div id='infoboxpic'><div id='infoboxpicin'><div id='infoboxpicimg' style='background-image: url(" + ingress.imagen + ");'></div></div></div>");
marker.addTo(LG_Ingress); // Añadimos al grupo de portales ingress
});
ControlLayer.addOverlay(LG_Circle20m,"20 Metros");
ControlLayer.addOverlay(LG_Ingress,"Ingress (<b>"+ (contador) + "</b>)");
ControlLayer.addOverlay(LG_ContadorPG,"Contador PO GY (<b>"+ ContMarkerNumCell14 + "</b>)");
let ContadorFaltan=0;
// Ponemos Marcadores con numero de pokeparadas y gyms en celda 14
for (a = 0; a < ContMarkerNumCell14; a++)
{
let i = ListIndex[a];
let NumMark = ArrayMarkerNumCell14[i].ContMark;
let TextMark = "";
var loc= midPoint(ArrayMarkerNumCell14[i].Lat1,ArrayMarkerNumCell14[i].Lon1,ArrayMarkerNumCell14[i].Lat2,ArrayMarkerNumCell14[i].Lon2);
let NumFalta = NumMark;
if ( NumMark > 1 )
{
if ( NumMark < 6 )
{
NumFalta = 6 - NumMark;
} else if ( NumMark < 20 )
{
NumFalta = 20 - NumMark;
} else { NumFalta = 0; };
};
let itotalpg = L.ExtraMarkers.icon
({
icon: 'fa-number',
shape: 'penta',
markerColor: 'orange-dark',
iconColor: 'white',
number: NumMark.toString(),
riseOnHover: true,
noHide: true,
// riseOffset : 10000,
});
if ( NumFalta > 0 )
{
TextMark = "<b> <p class='NumeroCoSi'>"+ NumFalta +" </p> <p style='font-size:large; text-align:center'> Más para nuevo Gym </p></b>";
if ( NumFalta <=2 ) { MarkForm = 'star' ; MarkCol = 'green-light' ; MarkICol = 'white'; }
else { MarkForm= 'square'; MarkCol = 'white'; MarkICol = 'black'; };
let ifaltag = L.ExtraMarkers.icon
({
icon: 'fa-number',
prefix: 'fa',
shape: MarkForm,
markerColor: MarkCol,
iconColor: MarkICol,
number: NumFalta.toString(),
riseOnHover: true,
noHide: true,
zIndexOffset: 5000,
// riseOffset : 10000,
});
marker = new L.Marker(loc, {title: "Falta para nuevo gym", icon: ifaltag} );
marker.addTo(LG_FaltanGym); // Añadimos al grupo de Faltan para gym
ContadorFaltan++;
}
else
{
TextMark = "<b> <p class='NumeroCoSi'> Máximo </p> <p style='font-size:large; text-align:center'> Número de Gyms Alcanzado </p></b>";
const cell = S2.S2Cell.FromLatLng(loc, 14);
const corners = cell.getCornerLatLngs();
new L.polyline([corners[0], corners[1], corners[2] , corners[3]], MarkerPoligonOptions14).addTo(LG_FaltanGym);
};
marker = new L.Marker(loc, {title: "Total pokeparadas y gyms celda 14", icon: itotalpg} );
marker.bindPopup( TextMark + "info:<br> Aparece Nuevo gym <b> 2a | 6a | 20a</b>");
marker.addTo(LG_ContadorPG); // Añadimos al grupo de totales PO GY
};
ControlLayer.addOverlay(LG_FaltanGym,"Para Gym (<b>"+ ContadorFaltan + "</b>)");
ControlLayer.addOverlay(LG_Celda17Fill,"Celda 17 Ocupada");
},
wanted: [ "gym" , "pokestop" , "gymex" , "Propuesta" , "Aceptadas" , "Sugerencia" , "Ingress" ],
debug: true
});
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Contar Pokeparadas y Gyms en celdas 14
const MaxArray = 2048-1; // Espacio para el array de celdas (1024 ,2048,4096,8192)
const AndIndex = 2048-1; //
var ListIndex = []; // Array de indices
function ContarPOGYC14(loc)
{
const cell = S2.S2Cell.FromLatLng(loc, 14);
const corners = cell.getCornerLatLngs();
let MarkIndex= ((~ cell.ij[0] ) ^ cell.ij[1]) & AndIndex; // Creamos un indice en la tabla de arrays
MarkerNumCell14.Lat1= corners[1].lat;
MarkerNumCell14.Lon1= corners[1].lng;
MarkerNumCell14.Lat2= corners[3].lat;
MarkerNumCell14.Lon2= corners[3].lng;
var Nuevorepe=0; // 1 = Nuevo o Repe
do
{
if ( ArrayMarkerNumCell14[MarkIndex] == undefined )
{
ArrayMarkerNumCell14[MarkIndex]= JSON.parse(JSON.stringify(MarkerNumCell14));
ListIndex[ContMarkerNumCell14]=MarkIndex;
ContMarkerNumCell14++;
Nuevorepe = 1;
} else
{
if( (ArrayMarkerNumCell14[MarkIndex].Lat1 == MarkerNumCell14.Lat1) && (ArrayMarkerNumCell14[MarkIndex].Lon1 == MarkerNumCell14.Lon1))
{
Nuevorepe=1; //Celda repetida
ArrayMarkerNumCell14[MarkIndex].ContMark++ // Incrementamos contador de marcador en celda
} else
{
MarkIndex= (MarkIndex+1) & MaxArray; // si array ocupado no igual, cogemos siguiente array
};
};
} while (Nuevorepe == 0);
};
////////////////////////////////////////////////////////////////////////////////////////////////
// Calcular el medio entre 2 puntos
function midPoint(lat1,lon1,lat2,lon2)
{
let dLon = (lon2 - lon1) * Math.PI / 180;
//convert to radians
lat1 = lat1 * Math.PI / 180;
lat2 = lat2 * Math.PI / 180;
lon1 = lon1 * Math.PI / 180;
let Bx = Math.cos(lat2) * Math.cos(dLon);
let By = Math.cos(lat2) * Math.sin(dLon);
let lat3 = Math.atan2(Math.sin(lat1) + Math.sin(lat2), Math.sqrt((Math.cos(lat1) + Bx) * (Math.cos(lat1) + Bx) + By * By));
let lon3 = lon1 + Math.atan2(By, Math.cos(lat1) + Bx);
return new L.latLng ((lat3 * 180 / Math.PI),(lon3 * 180 / Math.PI)); // Devolvemos valores a grados
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Overlay the S2 cells
// CREDIT: S2 cell drawing pretty much borrowed directly from
// https://gitlab.com/AlfonsoML/pogo-s2/blob/93cc77c1973b4978610ff25a85273d290e2754a0/s2check.user.js
let regionLayer;
var ColorCell17= '#000000';
var ColorCell14= '#FF0000';
const updateMapGrid = () => {
regionLayer.clearLayers();
const bounds = map.getBounds();
const seenCells = {};
const levels = {
17: {
color: ColorCell17, //'#000000',
opacity: 1,
weight: 1,
},
14: {
color: ColorCell14, //'#22CC44',
opacity: 0.6,
weight: 5,
},
};
const drawCell = (cell, options) => {
// corner points
const corners = cell.getCornerLatLngs();
// the level 6 cells have noticible errors with non-geodesic lines - and the larger level 4 cells are worse
// NOTE: we only draw two of the edges. as we draw all cells on screen, the other two edges will either be drawn
// from the other cell, or be off screen so we don't care
const region = L.polyline([corners[0], corners[1], corners[2]], {
fill: false,
clickable: false,
...options,
});
regionLayer.addLayer(region);
};
const drawCellAndNeighbors = (cell, options) => {
const cellStr = cell.toString();
if (!seenCells[cellStr]) {
// cell not visited - flag it as visited now
seenCells[cellStr] = true;
// is it on the screen?
const corners = cell.getCornerLatLngs();
const cellBounds = L.latLngBounds([corners[0], corners[1]]).extend(corners[2]).extend(corners[3]);
if (cellBounds.intersects(bounds)) {
// on screen - draw it
drawCell(cell, options);
// and recurse to our neighbors
const neighbors = cell.getNeighbors();
for (let i = 0; i < neighbors.length; i++) {
drawCellAndNeighbors(neighbors[i], options);
};
};
};
};
// center cell
const zoom = map.getZoom();
Object.keys(levels).forEach(level => {
const options = levels[level];
if (level == 14 && zoom >= 15 ) // nivel de zoom que sera visible celda 14
{
const cell = S2.S2Cell.FromLatLng(map.getCenter(), level);
drawCellAndNeighbors(cell, options);
}
else if (level == 17 && zoom >= 16 ) // nivel de zoom que sera visible celda 17
{
if ( zoom >= (ZoomMax-1) ) { ColorCell17= '#FFFFFF'; } // Celda 17 color blanco
else { ColorCell17= '#000000'; }; // celda 17 color negro
const cell = S2.S2Cell.FromLatLng(map.getCenter(), level);
drawCellAndNeighbors(cell, options);
};
});
};
regionLayer = L.layerGroup();
map.addLayer(regionLayer);
map.on('moveend', updateMapGrid);
updateTiles();
updateMapGrid();
</script>
</body>
</html>