PageSourceSearch

https://mairievendes.fr/wp-content/plugins/ultimate-maps-by-supsystic/modules/maps/js/core.maps.js?ver=1.3.3

js mairievendes.fr collected 2026-10-03 02:47:06 UTC 19,840 bytes, 553 lines download raw bytes

1function umsBaseMap(elementId, mapData, engine, additionalParams) {
2  mapData = mapData ? mapData : {};
3  additionalParams = additionalParams ? additionalParams : {};
4  var defaults = {};
5  this._engine = engine;
6  this._fullEngine = additionalParams.fullEngine ? additionalParams.fullEngine : this._engine;
7  /*var defaults = {
8		center: new google.maps.LatLng(40.69847032728747, -73.9514422416687)
9	,	zoom: 8
10	//,	mapTypeId: google.maps.MapTypeId.ROADMAP
11	};
12	if(params.map_center && params.map_center.coord_x && params.map_center.coord_y) {
13		params.center = new google.maps.LatLng(params.map_center.coord_x, params.map_center.coord_y);
14	}
15	if(params.zoom) {
16		params.zoom = parseInt(params.zoom);
17	}
18	if(!UMS_DATA.isAdmin && params.zoom_type == 'zoom_level' && params.zoom_mobile && jQuery(document).width() < 768) {
19		params.zoom = parseInt(params.zoom_mobile);
20	}*/
21  /*if (typeof(elementId) === 'string') {
22		elementId = jQuery(elementId)[0];
23	}*/
24  this._$markerInfoWndStyle = null;
25  this._elementId = elementId;
26  this._clearElementId = str_replace(this._elementId, '#', '');
27  this._element = typeof elementId === 'string' ? jQuery(elementId)[0] : elementId;
28  this._mapParams = jQuery.extend({}, defaults, mapData.params);
29  this._mapObj = null;
30  this._markers = [];
31  this._shapes = [];
32  this._heatmap = [];
33  this._kmlLayers = [];
34  this._clasterer = null;
35  this._clastererEnabled = false;
36  this._clastererMarkersGroupsStyles = [];
37  //this._eventListeners = {};
38  //this._layers = {};
39  //this.mapMarkersGroups = additionalData.markerGroups ? additionalData.markerGroups : [];
40  this._initComplete = false;
41  this.init();
42}
43umsBaseMap.prototype.getEngine = function () {
44  return this._engine;
45};
46umsBaseMap.prototype.init = function () {
47  this._beforeInit();
48  this._createMapObj();
49  this._refreshMarkerInfoWndStyle();
50  this._afterInit();
51  this._initComplete = true;
52};
53umsBaseMap.prototype._createMapObj = function () {
54  // Map object creation for inheritance should be here
55};
56umsBaseMap.prototype._beforeInit = function () {
57  jQuery(document).trigger('umsBeforeMapInit', this);
58};
59umsBaseMap.prototype.getParams = function () {
60  return this._mapParams;
61};
62umsBaseMap.prototype.getParam = function (key) {
63  return this._mapParams[key];
64};
65umsBaseMap.prototype.setParam = function (key, value) {
66  this._mapParams[key] = value;
67  return this;
68};
69umsBaseMap.prototype.resizeMapByHeight = function () {
70  if (!UMS_DATA.isAdmin && parseInt(this.getParam('adapt_map_to_screen_height')) && this.getRawMapInstance().map_display_mode != 'popup') {
71    var self = this;
72
73    function resizeHeight() {
74      var viewId = self.getParam('view_id'),
75        mapContainer = jQuery('#umsMapDetailsContainer_' + viewId),
76        mapContainerOffset = mapContainer.length ? mapContainer.offset() : false,
77        windowHeight = jQuery(window).height();
78
79      if (mapContainerOffset) {
80        jQuery('#umsMapDetailsContainer_' + viewId + ', #' + self.getParam('view_html_id')).each(function () {
81          var height = mapContainerOffset.top < windowHeight ? windowHeight - mapContainerOffset.top : windowHeight;
82          jQuery(this).height(height);
83        });
84        //self.refresh();
85      }
86    }
87    resizeHeight();
88    jQuery(window).bind('resize', resizeHeight);
89    jQuery(window).bind('orientationchange', resizeHeight);
90  }
91};
92umsBaseMap.prototype._afterInit = function () {
93  if (typeof this._mapParams.marker_clasterer !== 'undefined' && this._mapParams.marker_clasterer) {
94    this.enableClasterization(this._mapParams.marker_clasterer);
95  }
96  this.resizeMapByHeight();
97  jQuery(document).trigger('umsAfterMapInit', this);
98};
99umsBaseMap.prototype.addMarker = function (params) {
100  var newMarker = this._createMarkerObj(params);
101  this._markers.push(newMarker);
102  return newMarker;
103};
104umsBaseMap.prototype._createMarkerObj = function (params) {
105  // Marker object creation should be here
106  return umsMapLoader.initMarker(this, params);
107  //this._methodRedefineNotice('umsBaseMap.prototype.setCenter');
108  //return null;
109};
110umsBaseMap.prototype.getMarkerById = function (id) {
111  if (this._markers && this._markers.length) {
112    id = parseInt(id);
113    for (var i in this._markers) {
114      if (this._markers[i].getId && this._markers[i].getId() === id) return this._markers[i];
115    }
116  }
117  return false;
118};
119umsBaseMap.prototype.removeMarker = function (id) {
120  var marker = this.getMarkerById(id);
121  if (marker) {
122    marker.removeFromMap();
123  }
124};
125umsBaseMap.prototype.getAllMarkers = function () {
126  return this._markers;
127};
128umsBaseMap.prototype.addEventListener = function (event, callback) {
129  /*zoom_changed, dragend*/
130  this._methodRedefineNotice('umsBaseMap.prototype.addEventListener');
131};
132umsBaseMap.prototype.setCenter = function (lat, lng) {
133  this._methodRedefineNotice('umsBaseMap.prototype.setCenter');
134};
135umsBaseMap.prototype.getCenter = function () {
136  this._methodRedefineNotice('umsBaseMap.prototype.getCenter');
137};
138umsBaseMap.prototype.setZoom = function (zoomLevel) {
139  this._methodRedefineNotice('umsBaseMap.prototype.setZoom');
140};
141umsBaseMap.prototype.getZoom = function () {
142  this._methodRedefineNotice('umsBaseMap.prototype.getZoom');
143};
144umsBaseMap.prototype.setMapType = function (mapType) {
145  this._methodRedefineNotice('umsBaseMap.prototype.setMapType');
146};
147/**
148 * Should trigger after added or modified markers
149 */
150umsBaseMap.prototype.markersRefresh = function () {
151  var clasterer = this.getClasterer();
152
153  if (this._clastererEnabled && clasterer) {
154    this._refreshCluster();
155    /*clasterer.clearMarkers();
156		clasterer.addMarkers( this.getAllRawMarkers() );*/
157  }
158  jQuery(document).trigger('umsAfterMarkersRefresh', this);
159};
160umsBaseMap.prototype._refreshCluster = function () {
161  this._methodRedefineNotice('umsBaseMap.prototype._refreshCluster');
162};
163umsBaseMap.prototype.getAllRawMarkers = function () {
164  var res = [];
165  if (this._markers && this._markers.length) {
166    for (var i = 0; i < this._markers.length; i++) {
167      res.push(this._markers[i].getRawMarkerInstance());
168    }
169  }
170  return res;
171};
172
173umsBaseMap.prototype._methodRedefineNotice = function (methodName) {
174  console.log('[' + methodName + '] should be re-defined!');
175};
176umsBaseMap.prototype.clearMarkers = function () {
177  if (this._markers && this._markers.length) {
178    for (var i = 0; i < this._markers.length; i++) {
179      this._markers[i].removeFromMap();
180    }
181    this._markers = [];
182  }
183};
184umsBaseMap.prototype.clearMarkersByParam = function (param) {
185  if (this._markers && this._markers.length) {
186    for (var i = 0; i < this._markers.length; i++) {
187      if (this._markers[i].getMarkerParam(param)) {
188        this._markers[i].removeFromMap();
189        this._markers.splice(i, 1);
190        this.clearMarkersByParam(param);
191        break;
192      }
193    }
194  }
195};
196umsBaseMap.prototype._runAfterInitComplete = function (clb) {
197  // TODO: think and write
198};
199umsBaseMap.prototype.setNavigationBarMode = function (mode) {
200  this._methodRedefineNotice('umsBaseMap.prototype.setNavigationBarMode');
201};
202umsBaseMap.prototype.getNavigationBarMode = function () {
203  this._methodRedefineNotice('umsBaseMap.prototype.getNavigationBarMode');
204};
205umsBaseMap.prototype.enbZoom = function (mode) {
206  this._methodRedefineNotice('umsBaseMap.prototype.enbZoom');
207};
208umsBaseMap.prototype.enbDraggable = function (mode) {
209  this._methodRedefineNotice('umsBaseMap.prototype.enbDraggable');
210};
211umsBaseMap.prototype.enbWheelZoom = function (mode) {
212  this._methodRedefineNotice('umsBaseMap.prototype.enbWheelZoom');
213};
214umsBaseMap.prototype.geocodeQuery = function (search, clb) {
215  this._methodRedefineNotice('umsBaseMap.prototype.geocodeQuery');
216};
217
218umsBaseMap.prototype.getClasterer = function () {
219  if (this._clasterer) {
220    return this._clasterer;
221  }
222  return false;
223};
224umsBaseMap.prototype.setClasterer = function (clasterer) {
225  this._clasterer = clasterer;
226};
227
228umsBaseMap.prototype.geocodeSearchAutocomplete = function ($el, params) {
229  params = params || {};
230  var mapSelf = this;
231  $el = typeof $el === 'string' ? jQuery($el) : $el;
232  $el.keyup(function (event) {
233    // Ignore tab, enter, caps, end, home, arrows
234    if (toeInArrayUms(event.keyCode, [9, 13, 20, 35, 36, 37, 38, 39, 40])) return;
235
236    var searchData = jQuery.trim(jQuery(this).val());
237
238    if (searchData && searchData != '') {
239      if (typeof params.msgEl === 'string') {
240        params.msgEl = jQuery(params.msgEl);
241      }
242      params.msgEl.showLoaderUms();
243      var self = this;
244
245      jQuery(this).autocomplete({
246        source: function (request, response) {
247          var autocomleateData = typeof params.additionalData != 'undefined' ? umsAutocomleateData(params.additionalData, request.term) : [];
248
249          mapSelf.geocodeQuery(
250            searchData,
251            function (results) {
252              params.msgEl.html('');
253              for (var i = 0; i < results.length; i++) {
254                autocomleateData.push({
255                  label: results[i].formatted_address,
256                  lat: results[i].lat,
257                  lng: results[i].lng,
258                });
259              }
260              response(autocomleateData);
261            },
262            function (event) {
263              if (autocomleateData && autocomleateData.length > 0) {
264                response(autocomleateData);
265              } else {
266                //var notFoundMsg = toeLangUms('Google can\'t find requested address coordinates, please try to modify search criterias.');
267                var notFoundMsg = toeLangUms('Nothing was found');
268
269                if (jQuery(self).parent().find('.ui-helper-hidden-accessible').length) {
270                  jQuery(self).parent().find('.ui-helper-hidden-accessible').html(notFoundMsg);
271                } else {
272                  params.msgEl.html(notFoundMsg);
273                }
274              }
275            }
276          );
277        },
278        select: function (event, ui) {
279          if (params.onSelect) {
280            params.onSelect(ui.item, event, ui);
281          }
282          jQuery(self).removeClass('ui-autocomplete-loading');
283        },
284      });
285
286      // Force imidiate search right after creation
287      jQuery(this).autocomplete('search');
288    }
289  });
290  function umsAutocomleateData(data, needle) {
291    var autocomleateData = [];
292
293    for (var i = 0; i < data.length; i++) {
294      for (var j = 0; j < data[i].length; j++) {
295        if (data[i][j]) {
296          var label = data[i][j].label.toString().toLowerCase(),
297            desc = data[i][j].marker_desc != 'undefined' ? data[i][j].marker_desc : '',
298            term = needle.toLowerCase();
299
300          if (label.indexOf(term) !== -1 || (desc && desc.indexOf(term) !== -1)) {
301            autocomleateData.push(data[i][j]);
302          }
303        }
304      }
305    }
306    return autocomleateData;
307  }
308};
309umsBaseMap.prototype.getRawMapInstance = function () {
310  return this._mapObj;
311};
312umsBaseMap.prototype.checkMarkersParams = function (markers, needToShow) {
313  if (markers && markers.length) {
314    for (var i = 0; i < markers.length; i++) {
315      var markerParams = markers[i].getMarkerParam('params'),
316        showDescription = parseInt(markerParams.show_description);
317      if (showDescription || needToShow) {
318        markers[i].showInfoWnd(true, showDescription, true);
319      }
320    }
321  }
322};
323umsBaseMap.prototype.setMarkerInfoWndWidthUnits = function (type) {
324  this.setParam('marker_infownd_width_units', type);
325  this._refreshMarkerInfoWndStyle();
326};
327umsBaseMap.prototype.setMarkerInfoWndWidth = function (width) {
328  this.setParam('marker_infownd_width', width);
329  this._refreshMarkerInfoWndStyle();
330};
331umsBaseMap.prototype.setMarkerInfoWndHeightUnits = function (type) {
332  this.setParam('marker_infownd_height_units', type);
333  this._refreshMarkerInfoWndStyle();
334};
335umsBaseMap.prototype.setMarkerInfoWndHeight = function (height) {
336  this.setParam('marker_infownd_height', height);
337  this._refreshMarkerInfoWndStyle();
338};
339
340umsBaseMap.prototype.setMarkerInfoWndTitleColor = function (color) {
341  this.setParam('marker_title_color', color);
342  this._refreshMarkerInfoWndStyle();
343};
344umsBaseMap.prototype.setMarkerInfoWndBgColor = function (color) {
345  this.setParam('marker_infownd_bg_color', color);
346  this._refreshMarkerInfoWndStyle();
347};
348umsBaseMap.prototype.setMarkerInfoWndTitleSize = function (size) {
349  this.setParam('marker_title_size', size);
350  this._refreshMarkerInfoWndStyle();
351};
352umsBaseMap.prototype.setMarkerInfoWndDescSize = function (size) {
353  this.setParam('marker_desc_size', size);
354  this._refreshMarkerInfoWndStyle();
355};
356umsBaseMap.prototype._refreshMarkerInfoWndStyle = function () {
357  var styleHtml = this._generateMarkerInfoWndStyle();
358  if (!styleHtml) return;
359  if (!this._$markerInfoWndStyle) {
360    this._$markerInfoWndStyle = jQuery('<style id="umsMarkerInfoWndStyle_' + this._clearElementId + '">').appendTo('body');
361  }
362  this._$markerInfoWndStyle.html(styleHtml);
363};
364umsBaseMap.prototype._generateMarkerInfoWndStyle = function () {
365  //this._methodRedefineNotice('umsBaseMap.prototype._generateMarkerInfoWndStyle');
366  // If map require generate style - it should re-define this
367  return false;
368};
369umsBaseMap.prototype._getCreateCoords = function () {
370  return this._mapParams.map_center && this._mapParams.map_center.coord_x && this._mapParams.map_center.coord_x !== '' && this._mapParams.map_center.coord_y && this._mapParams.map_center.coord_y !== '' ? this._mapParams.map_center : { coord_x: 51.50632, coord_y: -0.12714 };
371};
372umsBaseMap.prototype.enableClasterization = function (clasterType, needTrigger) {
373  this._clastererEnabled = true;
374};
375umsBaseMap.prototype.disableClasterization = function () {
376  this._clastererEnabled = false;
377};
378umsBaseMap.prototype.setClusterSize = function (size) {
379  this._methodRedefineNotice('umsBaseMap.prototype.geocodeQuery');
380};
381umsBaseMap.prototype.getViewId = function () {
382  return this._mapParams.view_id;
383};
384umsBaseMap.prototype.getViewHtmlId = function () {
385  return this._mapParams.view_html_id;
386};
387umsBaseMap.prototype.getId = function () {
388  return this._mapParams.id;
389};
390umsBaseMap.prototype.closeAllInfoWnd = function () {
391  if (this._markers && this._markers.length) {
392    for (var i = 0; i < this._markers.length; i++) {
393      this._markers[i].hideInfoWnd();
394    }
395  }
396};
397umsBaseMap.prototype.clearShapes = function () {
398  if (this._shapes && this._shapes.length) {
399    for (var i = 0; i < this._shapes.length; i++) {
400      this._shapes[i].setMap(null);
401    }
402    this._shapes = [];
403  }
404};
405umsBaseMap.prototype.addShape = function (params) {
406  var newShape = umsShapeLoader.initShape(this, params);
407  this._shapes.push(newShape);
408  return newShape;
409};
410umsBaseMap.prototype.addHeatmap = function (params) {
411  //var heatmap = new umsGoogleHeatmap(this, params);
412  // TODO: Add here heatmap object generation
413  this._heatmap.push(heatmap);
414  return heatmap;
415};
416
417umsBaseMap.prototype.getShapeById = function (id) {
418  if (this._shapes && this._shapes.length) {
419    for (var i in this._shapes) {
420      if (this._shapes[i].getId() == id) return this._shapes[i];
421    }
422  }
423  return false;
424};
425umsBaseMap.prototype.getHeatmap = function () {
426  if (this._heatmap && this._heatmap.length) {
427    // There is only one heatmap layer on the map
428    return this._heatmap[0];
429  }
430  return false;
431};
432
433umsBaseMap.prototype.removeShape = function (id) {
434  var shape = this.getShapeById(id);
435  if (shape) {
436    shape.removeFromMap();
437  }
438};
439
440umsBaseMap.prototype.getAllShapes = function () {
441  return this._shapes;
442};
443umsBaseMap.prototype.addKmlLayer = function (layer) {
444  this._kmlLayers.push(layer);
445};
446umsBaseMap.prototype.removeKmlLayerByUrl = function (url) {
447  if (this._kmlLayers.length) {
448    for (var i = 0; i < this._kmlLayers.length; i++) {
449      if (this._kmlLayers[i].getUrl() == url) {
450        this._kmlLayers[i].removeFromMap();
451        this._kmlLayers.splice(i, 1);
452        break;
453      }
454    }
455  }
456};
457umsBaseMap.prototype._setMinZoomLevel = function () {
458  var curZoom = this.getZoom();
459  var minZoom = parseInt(this._mapParams.zoom_min) ? parseInt(this._mapParams.zoom_min) : null;
460  //this.getRawMapInstance().setOptions({minZoom: minZoom});
461  if (curZoom < minZoom) this.setZoom(minZoom);
462};
463umsBaseMap.prototype._setMaxZoomLevel = function () {
464  var maxZoom = parseInt(this._mapParams.zoom_max) ? parseInt(this._mapParams.zoom_max) : null;
465  //this.getRawMapInstance().setOptions({maxZoom: maxZoom});
466  if (this.getRawMapInstance().zoom > maxZoom) this.setZoom(maxZoom);
467};
468/*umsBaseMap.prototype._fixZoomLevel = function() {
469	var eventHandle = this._getEventListenerHandle('zoom_changed', 'zoomChanged');
470	if(!eventHandle) {
471		eventHandle = google.maps.event.addListener(this.getRawMapInstance(), 'zoom_changed', jQuery.proxy(function(){
472			var minZoom = parseInt(this.getParam('zoom_min'))
473			,	maxZoom = parseInt(this.getParam('zoom_max'));
474			if (this.getZoom() < minZoom) {
475				this.setZoom(minZoom);
476				if(GMP_DATA.isAdmin && this._getEventListenerHandle('idle', 'enableClasterization'))
477					google.maps.event.trigger(this.getRawMapInstance(), 'idle');
478			}
479			if (this.getZoom() > maxZoom) {
480				this.setZoom(maxZoom);
481				if(GMP_DATA.isAdmin && this._getEventListenerHandle('idle', 'enableClasterization'))
482					google.maps.event.trigger(this.getRawMapInstance(), 'idle');
483			}
484		}, this));
485		this._addEventListenerHandle('zoom_changed', 'zoomChanged', eventHandle);
486	}
487};*/
488var umsMapLoader = {
489  initMap: function (elementId, mapData, additionalParams) {
490    var engine = umsGetMapsEngine(mapData);
491    additionalParams = additionalParams ? additionalParams : {};
492    additionalParams.fullEngine = umsGetMapsFullEngine(mapData);
493    return new window['ums' + toeStrFirstUp(engine) + 'Map'](elementId, mapData, engine, additionalParams);
494  },
495  initMarker: function (map, markerParams) {
496    return new window['ums' + toeStrFirstUp(map.getEngine()) + 'Marker'](map, markerParams);
497  },
498};
499var g_umsMapLoadObserver = {
500  _loaded: {},
501  setLoaded: function (engine) {
502    this._loaded[engine] = true;
503  },
504  isLoaded: function (engine) {
505    return this._loaded[engine];
506  },
507  trigger: function (engine, clb) {
508    if (this.isLoaded(engine)) {
509      clb();
510    } else {
511      var self = this;
512      setTimeout(function () {
513        self.trigger(engine, clb);
514      }, 500);
515    }
516  },
517};
518function umsGetMapsEngine(map) {
519  var fullEngine = umsGetMapsFullEngine(map);
520  if (fullEngine.indexOf('l-') === 0) {
521    return 'leaflet';
522  }
523  return fullEngine;
524}
525function umsGetMapsFullEngine(map) {
526  // This can be object inherited from umsBaseMap
527  if (map && typeof map.getEngine === 'function') {
528    return map.getEngine();
529  }
530  // Or just map set from database
531  if (map && map.engine && map.engine !== '') {
532    return map.engine;
533  }
534  return UMS_DATA.engine;
535}
536function gmpAutocomleateData(data, needle) {
537  var autocomleateData = [];
538
539  for (var i = 0; i < data.length; i++) {
540    for (var j = 0; j < data[i].length; j++) {
541      if (data[i][j]) {
542        var label = data[i][j].label.toString().toLowerCase(),
543          desc = data[i][j].marker_desc != 'undefined' ? data[i][j].marker_desc : '',
544          term = needle.toLowerCase();
545
546        if (label.indexOf(term) !== -1 || (desc && desc.indexOf(term) !== -1)) {
547          autocomleateData.push(data[i][j]);
548        }
549      }
550    }
551  }
552  return autocomleateData;
553}

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.