PageSourceSearch

https://villailpoggiale.it/modules/contrib/geolocation/js/geolocation-map.js?v=8.x-3.x

js villailpoggiale.it collected 2026-09-26 15:00:13 UTC 3,354 bytes, 114 lines download raw bytes

1/**
2 * @file
3 * Javascript for the Geolocation map formatter.
4 */
5
6(function ($, Drupal) {
7
8  'use strict';
9
10  /**
11   * Find and display all maps.
12   *
13   * @type {Drupal~behavior}
14   *
15   * @prop {Drupal~behaviorAttach} attach
16   *   Attaches Geolocation Maps formatter functionality to relevant elements.
17   */
18  Drupal.behaviors.geolocationMap = {
19
20    /**
21     * @param context
22     * @param drupalSettings
23     * @param {Object} drupalSettings.geolocation
24     */
25    attach: function (context, drupalSettings) {
26      $('.geolocation-map-wrapper').once('geolocation-map-processed').each(function (index, item) {
27        var mapWrapper = $(item);
28        var mapSettings = {};
29        var reset = false;
30        mapSettings.id = mapWrapper.attr('id');
31        mapSettings.wrapper = mapWrapper;
32
33        if (mapWrapper.length === 0) {
34          return;
35        }
36
37        mapSettings.lat = 0;
38        mapSettings.lng = 0;
39
40        if (
41          mapWrapper.data('centre-lat')
42          && mapWrapper.data('centre-lng')
43        ) {
44          mapSettings.lat = Number(mapWrapper.data('centre-lat'));
45          mapSettings.lng = Number(mapWrapper.data('centre-lng'));
46        }
47
48        if (mapWrapper.data('map-type')) {
49          mapSettings.type = mapWrapper.data('map-type');
50        }
51
52        if (typeof drupalSettings.geolocation === 'undefined') {
53          console.error("Bailing out for lack of settings.");  // eslint-disable-line no-console .
54          return;
55        }
56
57        $.each(drupalSettings.geolocation.maps, function (mapId, currentSettings) {
58          if (mapId === mapSettings.id) {
59            mapSettings = $.extend(currentSettings, mapSettings);
60          }
61        });
62
63        if (mapWrapper.parent().hasClass('preview-section')) {
64          if (mapWrapper.parentsUntil('#views-live-preview').length) {
65            reset = true;
66          }
67        }
68
69        var map = Drupal.geolocation.Factory(mapSettings, reset);
70
71        if (!map) {
72          mapWrapper.removeOnce('geolocation-map-processed');
73          return;
74        }
75
76        map.addInitializedCallback(function (map) {
77          map.removeControls();
78          $('.geolocation-map-controls > *', map.wrapper).each(function (index, control) {
79            map.addControl(control);
80          });
81
82          map.removeMapMarkers();
83          var locations = map.loadMarkersFromContainer();
84          $.each(locations, function (index, location) {
85            map.setMapMarker(location);
86          });
87
88          map.removeShapes();
89          var shapes = map.loadShapesFromContainer();
90          $.each(shapes, function (index, shape) {
91            map.addShape(shape);
92          });
93
94          map.setCenter();
95
96          map.wrapper.find('.geolocation-location').hide();
97        });
98
99        map.addUpdatedCallback(function (map, mapSettings) {
100          map.settings = $.extend(map.settings, mapSettings.settings);
101          map.wrapper = mapSettings.wrapper;
102          mapSettings.wrapper.find('.geolocation-map-container').replaceWith(map.container);
103          map.lat = mapSettings.lat;
104          map.lng = mapSettings.lng;
105          if (typeof mapSettings.map_center !== 'undefined') {
106            map.mapCenter = mapSettings.map_center;
107          }
108        });
109      });
110    },
111    detach: function (context, drupalSettings) {}
112  };
113
114})(jQuery, Drupal);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.