VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/webtrees/resources/views/modules/place-hierarchy/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/webtrees/resources/views/modules/place-hierarchy/map.phtml
<?php

declare(strict_types=1);

use Fisharebest\Webtrees\View;

/**
 * @var array<mixed> $data
 * @var object       $leaflet_config
 */

?>

<div class="row gchart wt-place-hierarchy-wrapper wt-fullscreen-container">
    <div id="wt-map" class="col-sm-9 wt-ajax-load wt-map" dir="ltr"></div>
    <ul class="col-sm-3 wt-map-sidebar wt-page-options-value list-unstyled px-md-1 mb-0"></ul>
</div>

<?php View::push('javascript') ?>
<script>
  'use strict';

  (function () {
    const config = <?= json_encode($leaflet_config, JSON_THROW_ON_ERROR) ?>;

    let map = null;
    const sidebar = document.querySelector('.wt-map-sidebar');

    const scrollOptions = {
      behavior: "smooth",
      block: "nearest",
      inline: "start"
    };

    // Map components
    let markers = L.markerClusterGroup({
      showCoverageOnHover: false,
    });

    /**
     * Passed to resetControl to
     * perform necessary reset actions on map
     *
     * @param {Event} event
     */
    let resetCallback = function (event) {
      event.preventDefault();
      map.flyToBounds(markers.getBounds(), { padding: [50, 30], maxZoom: 15 });
    };

    /**
     * @private
     */
    let _drawMap = function () {
      map = webtrees.buildLeafletJsMap('wt-map', config, resetCallback);
    };

    /**
     * @private
     */
    let _buildMapData = function () {
      let data = <?= json_encode($data['markers'], JSON_THROW_ON_ERROR) ?>;

      let geoJsonLayer = L.geoJson(data, {
        pointToLayer: function (feature, latlng) {
          return new L.Marker(latlng, {
            icon: L.BeautifyIcon.icon({
              icon: 'bullseye fas',
              borderColor: 'transparent',
              backgroundColor: '#1e90ff',
              iconShape: 'marker',
              textColor: 'white',
            }),
            title: feature.properties.tooltip,
            id: feature.id,
          })
            .on('popupopen', function (e) {
              let item = document.querySelector('.mapped[data-wt-feature-id="' + e.target.feature.id + '"]');
              item.classList.add('messagebox');
              item.scrollIntoView(scrollOptions);
            })
            .on('popupclose', function () {
              sidebar.querySelectorAll('.mapped').forEach(e => e.classList.remove('messagebox'));
            });
        },
        onEachFeature: function (feature, layer) {
          layer.bindPopup(feature.properties.popup);
        },
      });

      if (data.features.length > 0) {
        markers.addLayer(geoJsonLayer);
        map.addLayer(markers);
      }

      map.fitBounds(<?= json_encode($data['bounds'], JSON_THROW_ON_ERROR) ?>, { padding: [50, 30] });
      sidebar.innerHTML = <?= json_encode($data['sidebar'], JSON_THROW_ON_ERROR) ?>;
   };

    window.onload = function() {
      // Activate marker popup when sidebar entry clicked
      sidebar.querySelectorAll('.mapped').forEach((element) => {
        var eventId = parseInt(element.dataset.wtFeatureId);

        element.addEventListener('click', () => {
          // first close any existing
          map.closePopup();
          //find the marker corresponding to the clicked event
          let mkrLayer = markers.getLayers().filter(function (v) {
            return v.feature !== undefined && v.feature.id === eventId;
          });

          let mkr = mkrLayer.pop();

          markers.zoomToShowLayer(mkr, function (e) {
            mkr.openPopup();
          });

          return false;
        });

        // stop clicking on a person also opening the popup
        element.querySelectorAll('a').forEach((el) => {
          el.addEventListener('click', (e) => {
            e.stopPropagation();
          });
        });
      });
    }

    _drawMap();
    _buildMapData();
  })();
</script>
<?php View::endpush() ?>

VaKeR 2022