vue-geojson-view-ts 1.3.11 → 1.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-geojson-view-ts",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -312,10 +312,16 @@ export default defineComponent({
312
312
  feature.geometry.type === "MultiLineString" ||
313
313
  feature.geometry.type === "Point"
314
314
  ) {
315
+ const self = this;
315
316
  L.geoJson(feature, {
316
317
  pointToLayer: this.getPointToLayer.bind(this),
317
318
  onEachFeature: function (feature, layer) {
318
319
  featureGroup.addLayer(layer);
320
+ // Mostrar popup solo para Point
321
+ if (feature.geometry.type === "Point") {
322
+ var popupContent = self.getPopupContent(feature);
323
+ layer.bindPopup(popupContent);
324
+ }
319
325
  },
320
326
  });
321
327
  }
@@ -329,9 +335,15 @@ export default defineComponent({
329
335
  item.geometry.type === "Point" ||
330
336
  item.geometry.type === "MultiPoint"
331
337
  ) {
338
+ const self = this;
332
339
  L.geoJson(item, {
333
340
  onEachFeature: function (feature, layer) {
334
341
  featureGroup.addLayer(layer);
342
+ // Mostrar popup solo para Point
343
+ if (feature.geometry.type === "Point") {
344
+ var popupContent = self.getPopupContent(feature);
345
+ layer.bindPopup(popupContent);
346
+ }
335
347
  },
336
348
  });
337
349
  }
@@ -481,6 +493,37 @@ export default defineComponent({
481
493
  this.mapRender.panTo(newCenter, { animate: true, duration: 0.5 });
482
494
  }
483
495
  },
496
+ getPopupContent(feature: any): string {
497
+ // Puedes personalizar el contenido del popup aquí
498
+ const props = feature.properties || {};
499
+ // Solo toma en cuenta descripcion y fechaHoraLlegada
500
+ const descripcion = props.descripcion || "";
501
+ const fechaHoraLlegada = props.fechaHoraLlegada || "";
502
+ // url de la foto
503
+ const fotoId = props.fotoId || "";
504
+
505
+ // Formatear fecha a dd-MM-yyyy hh:mm:ss
506
+ let fechaFormateada = "";
507
+ if (fechaHoraLlegada) {
508
+ const fecha = new Date(fechaHoraLlegada);
509
+ const pad = (n: number) => n.toString().padStart(2, "0");
510
+ fechaFormateada = `${pad(fecha.getDate())}-${pad(
511
+ fecha.getMonth() + 1
512
+ )}-${fecha.getFullYear()} ${pad(fecha.getHours())}:${pad(
513
+ fecha.getMinutes()
514
+ )}:${pad(fecha.getSeconds())}`;
515
+ }
516
+ let html = "<div>";
517
+ if (fotoId) {
518
+ html += `<img src="${fotoId}" style="width: 200px; height: auto; margin-bottom: 5px;"><br>`;
519
+ }
520
+ html += `<b>Descripción:</b> ${descripcion}<br>`;
521
+ if (fechaFormateada) {
522
+ html += `<b>Fecha Hora Llegada:</b> ${fechaFormateada}<br>`;
523
+ }
524
+ html += "</div>";
525
+ return html;
526
+ },
484
527
  },
485
528
  watch: {
486
529
  coordinatesMap(newVal) {