PageSourceSearch

https://www.steyr-werke.at/wp-content/plugins/ultimate-maps-by-sup…/maps/js/engines/core.leaflet.js?ver=1.6.1

js steyr-werke.at collected 2026-10-07 01:24:03 UTC 17,954 bytes, 464 lines download raw bytes

1function umsLeafletMap(elementId, mapData, engine) {
2  this._zoomControl = null;
3  this._mainLayer = null;
4  this._mapTypes = null;
5  this._providers = null;
6  this._scaleControl = null;
7  this._provider = false;
8  this._providerData = null;
9  this._mainLayerType = null;
10  umsLeafletMap.superclass.constructor.apply(this, arguments);
11}
12extendUms(umsLeafletMap, umsBaseMap);
13umsLeafletMap.prototype._beforeInit = function () {
14  this._mapParams.zoom = this._mapParams.zoom ? parseInt(this._mapParams.zoom) : 10;
15
16  if (typeof this._mapParams.zoom_min !== 'undefined') {
17    this._mapParams.minZoom = parseInt(this._mapParams.zoom_min);
18  }
19  if (typeof this._mapParams.zoom_max !== 'undefined') {
20    this._mapParams.maxZoom = parseInt(this._mapParams.zoom_max);
21  }
22  if (typeof this._mapParams.mouse_wheel_zoom !== 'undefined') {
23    this._mapParams.scrollWheelZoom = parseInt(this._mapParams.mouse_wheel_zoom);
24  }
25  if (typeof this._mapParams.draggable !== 'undefined') {
26    var isMobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i) ? true : false;
27    switch (this._mapParams.draggable) {
28      case 'enable':
29        this._mapParams.dragging = 1;
30        break;
31      case 'disable':
32        this._mapParams.dragging = 0;
33        break;
34      case 'desktop':
35        if (!isMobile) {
36          this._mapParams.dragging = 1;
37        } else {
38          this._mapParams.dragging = 0;
39        }
40        break;
41      case 'mobile':
42        if (isMobile) {
43          this._mapParams.dragging = 1;
44        } else {
45          this._mapParams.dragging = 0;
46        }
47        break;
48    }
49  }
50  if (typeof this._mapParams.dbl_click_zoom !== 'undefined') {
51    this._mapParams.doubleClickZoom = parseInt(this._mapParams.dbl_click_zoom);
52  }
53  // We will do this after map will be init - to have zoom control object in our class
54  this._mapParams.zoomControl = false;
55  umsLeafletMap.superclass._beforeInit.apply(this, arguments);
56};
57umsLeafletMap.prototype._createMapObj = function () {
58  var centerCoords = this._getCreateCoords(),
59    params = jQuery.extend(this._mapParams, {
60      center: [centerCoords.coord_x, centerCoords.coord_y],
61    });
62  this._mapObj = L.map(this._clearElementId, params);
63  this._provider = this._getProviderEngine();
64  this._mainLayer = this._createMainLayer();
65};
66umsLeafletMap.prototype._createMainLayer = function (provider) {
67  var typeUrl = '',
68    typeData = null;
69
70  this._providerData = this._getProviderData(this._provider);
71  if (this._providerData) {
72    typeUrl = this._providerData.url;
73  } else if (typeof this._mapParams.map_type !== 'undefined' && this._mapTypeExists(this._mapParams.map_type)) {
74    typeUrl = this._providerData && this._providerData.typeToUrl ? this._providerData.typeToUrl(this._mapParams.map_type) : this._mapParams.map_type;
75    typeData = this._getMapTypeData(typeUrl);
76  } else {
77    typeUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
78    typeData = this._getMapTypeData(typeUrl);
79  }
80  var props = {
81    attribution: this._getAttributions(typeUrl),
82  };
83  if (this._providerData) {
84    if (this._providerData.props) {
85      props = jQuery.extend(props, this._providerData.props);
86    }
87    if (this._providerData.prepareProps) {
88      props = this._providerData.prepareProps(props);
89    }
90  }
91  this._mainLayerType = typeUrl;
92  return this._createLayerByType(typeUrl, typeData, props).addTo(this._mapObj);
93};
94umsLeafletMap.prototype._createLayerByType = function (typeUrl, typeData, props) {
95  if (typeData && typeData.layer === 'maplibre') {
96    return this._createMapLibreLayer(typeData);
97  }
98  return L.tileLayer(typeUrl, props);
99};
100umsLeafletMap.prototype._createMapLibreLayer = function (typeData) {
101  if (typeof L.maplibreGL === 'function' && typeof maplibregl !== 'undefined') {
102    return L.maplibreGL({
103      style: typeData.style,
104    });
105  }
106  if (window.console && console.error) {
107    console.error('OpenFreeMap requires MapLibre GL and the Leaflet MapLibre GL plugin.');
108  }
109  return L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
110    attribution: this._getAttributions('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'),
111  });
112};
113umsLeafletMap.prototype._getProviders = function () {
114  if (!this._providers) {
115    var self = this;
116    this._providers = {
117      mapbox: {
118        url: 'https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/256/{z}/{x}/{y}?access_token={accessToken}',
119        props: { id: 'streets-v11', accessToken: UMS_DATA.mapboxKey },
120        /*,	types: [
121					'mapbox.streets', 'mapbox.outdoors',
122					'mapbox.light','mapbox.dark','mapbox.satellite',
123					'mapbox.satellite-streets','mapbox.navigation-preview-day',
124					'mapbox.navigation-preview-night','mapbox.navigation-guidance-day','mapbox.navigation-guidance-night',
125					'mapbox.terrain-rgb'
126				]*/
127        typeToUrl: function (type) {
128          return str_replace(this.url, '{id}', type);
129        },
130        prepareProps: function (props) {
131          if (typeof self._mapParams.map_type !== 'undefined' && self._mapTypeExists(self._mapParams.map_type)) {
132            props.id = self._mapParams.map_type;
133          }
134          return props;
135        },
136      },
137      thunderforest: {
138        url: 'https://tile.thunderforest.com/{id}/{z}/{x}/{y}.png?apikey={apikey}',
139        props: { id: 'cycle', apikey: UMS_DATA.thunderforestKey },
140        //,	attr: '&copy; <a href="http://www.thunderforest.com/">Thunderforest</a>, &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
141        /*,	types: [
142					'cycle', 'transport', 'landscape', 'outdoors', 'transport-dark', 'spinal-map',
143					'pioneer', 'mobile-atlas', 'neighbourhood'
144				]*/
145        typeToUrl: function (type) {
146          return str_replace(this.url, '{id}', type);
147        },
148        prepareProps: function (props) {
149          if (typeof self._mapParams.map_type !== 'undefined' && self._mapTypeExists(self._mapParams.map_type)) {
150            props.id = self._mapParams.map_type;
151          }
152          return props;
153        },
154      },
155      maptiles: {
156        url: 'https://maptiles.p.rapidapi.com/{id}/map/v1/{z}/{x}/{y}.png?rapidapi-key={apikey}',
157        // url: 'https://maptiles.p.rapidapi.com/{id}/map/v1/{z}/{x}/{y}.png?rapidapi-key={apikey}'
158        props: { id: 'en', apikey: UMS_DATA.rapidapiKey },
159        //,	attr: '&copy; <a href="http://www.thunderforest.com/">Thunderforest</a>, &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
160        /*,	types: [
161						'cycle', 'transport', 'landscape', 'outdoors', 'transport-dark', 'spinal-map',
162						'pioneer', 'mobile-atlas', 'neighbourhood'
163					]*/
164        typeToUrl: function (type) {
165          return str_replace(this.url, '{id}', type);
166        },
167        prepareProps: function (props) {
168          if (typeof self._mapParams.map_type !== 'undefined' && self._mapTypeExists(self._mapParams.map_type)) {
169            props.id = self._mapParams.map_type;
170          }
171          return props;
172        },
173      },
174    };
175  }
176  return this._providers;
177};
178umsLeafletMap.prototype._getProviderData = function (provider) {
179  this._getProviders();
180  return this._providers[provider] ? this._providers[provider] : false;
181};
182umsLeafletMap.prototype._getProviderEngine = function () {
183  if (this._fullEngine.indexOf('l-') === 0) {
184    // like "l-mapbox" for example
185    return this._fullEngine.split('-')[1];
186  }
187  return this._fullEngine;
188};
189umsLeafletMap.prototype._afterInit = function () {
190  if (typeof this._mapParams.zoom_control !== 'undefined' && this._mapParams.zoom_control !== 'none') {
191    this.enbZoom(true);
192  }
193  umsLeafletMap.superclass._afterInit.apply(this, arguments);
194};
195umsLeafletMap.prototype.addEventListener = function (event, clb) {
196  if (event === 'zoom_changed') {
197    event = 'zoomend';
198  }
199  this._mapObj.addEventListener(event, clb);
200};
201umsLeafletMap.prototype.enbZoom = function (mode) {
202  var self = this;
203  var removeCtrl = function (ctrl) {
204    switch (ctrl) {
205      case 'zoom':
206        if (self._zoomControl) {
207          self._zoomControl.remove();
208          self._zoomControl = null;
209        }
210        break;
211      case 'scale':
212        if (self._scaleControl) {
213          self._scaleControl.remove();
214          self._scaleControl = null;
215        }
216        break;
217    }
218  };
219  if (mode) {
220    var mode = typeof this._mapParams.navigation_bar_mode !== 'undefined' ? this._mapParams.navigation_bar_mode : 'full';
221    if (toeInArrayUms(mode, ['full', 'zoom_only']) && !this._zoomControl) {
222      this._zoomControl = new L.control.zoom();
223      this._mapObj.addControl(this._zoomControl);
224      if (mode !== 'full') {
225        removeCtrl('scale');
226      }
227    }
228    if (toeInArrayUms(mode, ['full', 'scale_only']) && !this._scaleControl) {
229      this._scaleControl = new L.control.scale();
230      this._mapObj.addControl(this._scaleControl);
231      if (mode !== 'full') {
232        removeCtrl('zoom');
233      }
234    }
235  } else {
236    removeCtrl('zoom');
237    removeCtrl('scale');
238  }
239};
240umsLeafletMap.prototype.enbDraggable = function (mode) {
241  var isMobile = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i) ? true : false;
242  switch (mode) {
243    case 'enable':
244      this._mapObj.dragging.enable();
245      break;
246    case 'disable':
247      this._mapObj.dragging.disable();
248      break;
249    case 'desktop':
250      if (!isMobile) {
251        this._mapObj.dragging.enable();
252      } else {
253        this._mapObj.dragging.disable();
254      }
255      break;
256    case 'mobile':
257      if (isMobile) {
258        this._mapObj.dragging.enable();
259      } else {
260        this._mapObj.dragging.disable();
261      }
262      break;
263  }
264};
265umsLeafletMap.prototype.setCenter = function (lat, lng) {
266  this._mapObj.panTo([lat, lng]);
267};
268umsLeafletMap.prototype.getCenter = function () {
269  var center = this._mapObj.getCenter();
270  return { lat: center.lat, lng: center.lng };
271};
272umsLeafletMap.prototype.setZoom = function (zoomLevel) {
273  this._mapObj.setZoom(zoomLevel);
274};
275umsLeafletMap.prototype.getZoom = function () {
276  return this._mapObj.getZoom();
277};
278umsLeafletMap.prototype.setNavigationBarMode = function (mode) {
279  if (typeof this._mapParams.zoom_control !== 'undefined' && this._mapParams.zoom_control !== 'none') {
280    this._mapParams.navigation_bar_mode = mode;
281    this.enbZoom(false);
282    this.enbZoom(true);
283  }
284};
285umsLeafletMap.prototype.enbWheelZoom = function (mode) {
286  mode ? this._mapObj.scrollWheelZoom.enable() : this._mapObj.scrollWheelZoom.disable();
287};
288umsLeafletMap.prototype.getNavigationBarMode = function () {
289  this._methodRedefineNotice('umsLeafletMap.prototype.getNavigationBarMode');
290};
291umsLeafletMap.prototype.setMapType = function (mapType) {
292  if (this._providerData && this._providerData.typeToUrl) {
293    this._mainLayer.setUrl(this._providerData.typeToUrl(mapType));
294  } else if (this._mapTypeExists(mapType)) {
295    if (this._mainLayer) {
296      this._mapObj.removeLayer(this._mainLayer);
297    }
298    this._mainLayerType = mapType;
299    this._mainLayer = this._createLayerByType(mapType, this._getMapTypeData(mapType), {
300      attribution: this._getAttributions(mapType),
301    }).addTo(this._mapObj);
302  }
303};
304umsLeafletMap.prototype.geocodeQuery = function (search, clb, errorClb) {
305  // Leaflet don't have it's own geocode. So use nominatim service. maybe we need to push it as a default fallback?
306  jQuery.ajax({
307    url: 'https://nominatim.openstreetmap.org/?q=' + search + '&format=json',
308    dataType: 'text',
309    success: function (data) {
310      if (clb) {
311        if (data) {
312          var r = JSON.parse(data);
313          if (r) {
314            var formattedResult = [];
315            if (r && r.length > 0) {
316              for (var i = 0; i < r.length; i++) {
317                // All addresses in all geocoders should have same - our - format results
318                formattedResult.push({
319                  formatted_address: r[i].display_name,
320                  lat: r[i].lat,
321                  lng: r[i].lon,
322                });
323              }
324              clb(formattedResult);
325            }
326            return;
327          }
328        }
329        errorClb(data);
330        return;
331      } else console.log('So, what should I do next, ha?');
332    },
333  });
334};
335umsLeafletMap.prototype._generateMarkerInfoWndStyle = function () {
336  var res = [];
337  // Width
338
339  res.push(this._elementId + ' .marker-cluster {background-color: ' + this.getParam('marker_clasterer_border_color') + '; opacity:1;}');
340  res.push(this._elementId + ' .marker-cluster {color: ' + this.getParam('marker_clasterer_text_color') + ';}');
341  res.push(this._elementId + ' .marker-cluster div {background-color: ' + this.getParam('marker_clasterer_background_color') + '; opacity:1;}');
342
343  if (this.getParam('marker_infownd_width_units') === 'px') {
344    res.push(this._elementId + ' .leaflet-popup-content {width: ' + this.getParam('marker_infownd_width') + 'px;}');
345  }
346  // Height
347  if (this.getParam('marker_infownd_height_units') === 'px') {
348    res.push(this._elementId + ' .leaflet-popup-content {height: ' + this.getParam('marker_infownd_height') + 'px;}');
349  }
350  // Title style
351  res.push(this._elementId + ' .leaflet-popup-content .umsMarkerTitle {color: ' + this.getParam('marker_title_color') + '; font-size: ' + this.getParam('marker_title_size') + 'px}');
352  // Description
353  res.push(this._elementId + ' .leaflet-popup-content .umsMarkerDesc, ' + this._elementId + ' .leaflet-popup-content .umsMarkerDesc * {font-size: ' + this.getParam('marker_desc_size') + 'px}');
354  // Background
355  res.push(this._elementId + ' .leaflet-popup .leaflet-popup-content-wrapper, ' + this._elementId + ' .leaflet-popup .leaflet-popup-tip {background-color: ' + this.getParam('marker_infownd_bg_color') + ';}');
356  return res.join('');
357};
358umsLeafletMap.prototype._mapTypeExists = function (typeUrl) {
359  this._getMapTypes();
360  if (typeof this._mapTypes[typeUrl] !== 'undefined') return true;
361  /*if(this._providerData && this._providerData.types && this._providerData.types.indexOf(typeUrl) !== -1)
362		return true;*/
363  return false;
364};
365umsLeafletMap.prototype._getMapTypeData = function (typeUrl) {
366  this._getMapTypes();
367  return this._mapTypes[typeUrl] ? this._mapTypes[typeUrl] : false;
368};
369umsLeafletMap.prototype._getMapTypes = function () {
370  if (!this._mapTypes) {
371    var attr = '';
372    this._mapTypes = {};
373    var typesVarName = 'umsLeaFletTypes__' + (this._provider ? this._provider : this._fullEngine);
374    if (this._providerData) {
375      this._mapTypes[this._providerData.url] = {
376        // In first element there should be attr
377        attr: window[typesVarName][Object.keys(window[typesVarName])[0]].attr,
378      };
379    }
380    for (var typeName in window[typesVarName]) {
381      if (typeof window[typesVarName][typeName] === 'object') {
382        attr = window[typesVarName][typeName]['attr'];
383        this._mapTypes[typeName] = jQuery.extend({}, window[typesVarName][typeName]);
384        continue;
385      }
386      this._mapTypes[typeName] = {
387        attr: attr,
388      };
389    }
390  }
391  return this._mapTypes;
392};
393umsLeafletMap.prototype._getAttributions = function (typeUrl) {
394  this._getMapTypes();
395  return this._mapTypes[typeUrl] ? this._mapTypes[typeUrl].attr : '';
396};
397umsLeafletMap.prototype.enableClasterization = function (clasterType, needTrigger) {
398  switch (clasterType) {
399    case 'MarkerClusterer': // Support only this one for now
400      this._clearCluster();
401      this._createCluster();
402      this._addMarkersToCluster();
403      this._mapObj.addLayer(this._clasterer);
404      break;
405  }
406  this._clastererEnabled = true;
407};
408umsLeafletMap.prototype._addMarkersToCluster = function () {
409  if (this._markers.length > 0) {
410    for (var i = 0; i < this._markers.length; i++) {
411      this._clasterer.addLayer(this._markers[i].getRawMarkerInstance());
412      this._markers[i].removeFromMap();
413    }
414  }
415};
416umsLeafletMap.prototype.disableClasterization = function () {
417  this._clearCluster();
418  if (this._markers.length > 0) {
419    for (var i = 0; i < this._markers.length; i++) {
420      this._markers[i].addToMap();
421    }
422  }
423  this._clastererEnabled = false;
424};
425umsLeafletMap.prototype._clearCluster = function () {
426  if (this._clasterer) {
427    this._clasterer.remove();
428    this._clasterer = null;
429  }
430};
431umsLeafletMap.prototype._createCluster = function () {
432  if (!this._clasterer) {
433    var clasterGridSize = parseInt(this.getParam('marker_clasterer_grid_size'));
434    if (!clasterGridSize) clasterGridSize = 60;
435    var opts = {
436      maxClusterRadius: clasterGridSize,
437    };
438    this._clasterer = new L.MarkerClusterGroup(opts);
439  }
440};
441umsLeafletMap.prototype._refreshCluster = function () {
442  this._clearCluster();
443  this._createCluster();
444  this._addMarkersToCluster();
445  this._mapObj.addLayer(this._clasterer);
446};
447umsLeafletMap.prototype.setClusterSize = function (size) {
448  this.setParam('marker_clasterer_grid_size', size);
449  this._refreshCluster();
450};
451umsLeafletMap.prototype._setMinZoomLevel = function () {
452  umsLeafletMap.superclass._setMinZoomLevel.apply(this, arguments);
453  var minZoom = parseInt(this._mapParams.zoom_min) ? parseInt(this._mapParams.zoom_min) : null;
454  this._mapObj.setMinZoom(minZoom);
455};
456umsLeafletMap.prototype._setMaxZoomLevel = function () {
457  umsLeafletMap.superclass._setMaxZoomLevel.apply(this, arguments);
458  var maxZoom = parseInt(this._mapParams.zoom_max) ? parseInt(this._mapParams.zoom_max) : null;
459  this._mapObj.setMaxZoom(maxZoom);
460};
461function umsLeafletMapsLoadComplete() {
462  g_umsMapLoadObserver.setLoaded('leaflet');
463}
464umsLeafletMapsLoadComplete();

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.