https://www.zbb.ch/typo3temp/assets/compressed/merged-ad081541ea9cc4990fa6820a8dc5a907.js?1748867890
1 2/*************************************************************** 3 * Copyright notice 4 * 5 * (c) 2019 Stefan Hug <[email protected]> Webworker Company 6 * All rights reserved 7 * 8 * This script is part of the TYPO3 project. The TYPO3 project is 9 * free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * The GNU General Public License can be found at 15 * http://www.gnu.org/copyleft/gpl.html. 16 * 17 * This script is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * This copyright notice MUST APPEAR in all copies of the script! 23 ***************************************************************/ 24MapManager = function (options) { 25 this.construct(options); 26}; 27 28MapManager.prototype = { 29 30 options: null, 31 mapOptions : [], 32 markers : [], 33 infoWindows: [], 34 polylines: [], 35 additionalMarker: [], 36 additionalInfoWindows: [], 37 additionalPolylines: [], 38 lastPolyLineIndex: 5, 39 lastAdditionalMarkerPosition: 0, 40 mapTypeId: '', 41 42 construct: function (options) { 43 this.reset(options); 44 }, 45 46 /** 47 * reset the map manager 48 */ 49 reset: function (options) { 50 this.polylines = []; 51 this.additionalPolylines = []; 52 this.infoWindows = []; 53 this.markers = []; 54 this.additionalMarker = []; 55 this.options = options; 56 this.mapOptions = options['mapOptions']; 57 this.lastPolyLineIndex = 5; 58 this.lastAdditionalMarkerPosition = 0; 59 this.init(); 60 }, 61 62 init: function () { 63 var layerOptions = this.getLayerOptions(); 64 if (typeof layerOptions !== "undefined"){ 65 if (layerOptions.length) { 66 for (var i = 0; i < layerOptions.length; i++) { 67 switch (layerOptions[i].drawFunctionName) { 68 case 'drawMarker': 69 this.addMarker(layerOptions[i]); 70 break; 71 case 'drawInfoBox': 72 case 'drawInfoWindow': 73 this.addInfoWindow(layerOptions[i]); 74 break; 75 case 'drawPolyline': 76 this.addPolyline(layerOptions[i]); 77 break; 78 } 79 } 80 } 81 } 82 }, 83 84 clearAdditionalData: function () { 85 this.additionalMarker= []; 86 this.additionalInfoWindows= []; 87 this.additionalPolylines= []; 88 }, 89 90 /** 91 * Add marker 92 * @param marker 93 */ 94 addMarker: function (marker) { 95 marker.options.uid = marker.uid; 96 marker.options.position = eval(marker.options.position); 97 marker.options.icon = eval(marker.options.icon); 98 99 100 this.markers.push(marker.options); 101 }, 102 103 /** 104 * Returns the markers 105 * @returns {Array} 106 */ 107 getMarkers: function () { 108 return this.markers; 109 }, 110 111 112 /** 113 * Returns the infowindow by uid 114 * @param uid 115 * @returns {*} 116 */ 117 getMarkerByUid: function (uid) { 118 var index = this.markers.findIndex(x => x.uid ===uid); 119 return this.markers[index]; 120 }, 121 122 /** 123 * Add Infowindow 124 * @param infobox 125 */ 126 addInfoWindow: function (infobox) { 127 infobox.options.uid = infobox.linkToLayerUid 128 this.infoWindows.push(infobox.options); 129 }, 130 131 /** 132 * Returns the infowindows 133 * @returns {Array} 134 */ 135 getInfoWindows: function () { 136 return this.infoWindows; 137 }, 138 139 /** 140 * Returns the infowindow by uid 141 * @param uid 142 * @returns {*} 143 */ 144 getInfoWindowIndexByUid: function (uid) { 145 var index = this.infoWindows.findIndex(x => x.uid ===uid); 146 return index; 147 }, 148 149 /** 150 * Returns the infowindow by uid 151 * @param uid 152 * @returns {*} 153 */ 154 getInfoWindowByUid: function (uid) { 155 var index = this.getInfoWindowIndexByUid(uid); 156 return this.infoWindows[index]; 157 }, 158 159 /** 160 * Returns the infowindow by uid 161 * @param uid 162 * @returns {*} 163 */ 164 getAdditionalInfoWindowIndexByUid: function (uid) { 165 var index = this.additionalInfoWindows.findIndex(x => x.uid ===uid); 166 return index; 167 }, 168 169 /** 170 * Add a polyline 171 * @param polyline 172 */ 173 addPolyline: function (polyline) { 174 var path = []; 175 for (var i = 0; i < polyline.options.path.length; i++) { 176 path.push(eval(polyline.options.path[i])); 177 } 178 polyline.options.path = path; 179 this.polylines.push(polyline.options); 180 }, 181 182 /** 183 * Returns the polylines 184 * @returns {Array} 185 */ 186 getPolylines: function () { 187 188 var polylines = []; 189 190 for (var i = 0; i < this.polylines.length; i++) { 191 polylines.push(this.polylines[i]); 192 } 193 for (var i = 0; i < this.additionalPolylines.length; i++) { 194 polylines.push(this.additionalPolylines[i]); 195 } 196 return polylines; 197 }, 198 199 /** 200 * 201 * @returns {Array} 202 */ 203 getMapOptions: function () { 204 this.mapOptions.center = eval(this.mapOptions.center); 205 this.mapOptions.fullscreenControl = false;
206 207 208 if(this.mapOptions.mapTypeId == 'google.maps.MapTypeId.winter'){ 209 this.mapOptions.mapTypeId = 'winter'; 210 } else { 211 this.mapOptions.mapTypeId = eval(this.mapOptions.mapTypeId); 212 } 213 214 this.mapTypeId = this.mapOptions.mapTypeId; 215 216 return this.mapOptions; 217 }, 218 219 /** 220 * 221 * @returns {Array} 222 */ 223 getUpdateMapOptions: function () { 224 this.mapOptions.center = eval(this.mapOptions.center); 225 this.mapOptions.fullscreenControl = false; 226 this.mapOptions.mapTypeId = this.getMapTypeId(); 227 return this.mapOptions; 228 }, 229 230 /** 231 * 232 */ 233 setMapOptions: function (mapOptions) { 234 this.mapOptions = mapOptions; 235 }, 236 237 /** 238 * Returns the LayerOptions 239 * @returns {{}} 240 */ 241 getLayerOptions: function () { 242 return this.options.layerOptions; 243 }, 244 245 /** 246 * Sets the additional layer options 247 * @param additionalOptions 248 */ 249 setAdditionalLayerOptions: function (additionalOptions) { 250 this.clearAdditionalData(); 251 for (var i = 0; i < additionalOptions.length; i++) { 252 switch(additionalOptions[i].drawFunctionName){ 253 case 'drawMarker': 254 this.addAdditionalMarkers(additionalOptions[i]); 255 break; 256 case 'drawInfoBox': 257 this.addAdditionalInfowWindows(additionalOptions[i]); 258 break; 259 case 'drawPolyline': 260 this.addAdditionalPolylines(additionalOptions[i]); 261 break; 262 } 263 } 264 }, 265 266 /** 267 * Add a polyline 268 * @param polyline 269 */ 270 addAdditionalPolylines: function (polyline) { 271 var path = []; 272 for (var i = 0; i < polyline.options.path.length; i++) { 273 path.push(eval(polyline.options.path[i])); 274 } 275 polyline.options.id = polyline.uid; 276 polyline.options.path = path; 277 this.additionalPolylines.push(polyline.options); 278 }, 279 280 /** 281 * add additional marker 282 * @param marker 283 */ 284 addAdditionalMarkers: function(marker){ 285 marker.options.uid = marker.uid; 286 marker.options.position = eval(marker.options.position); 287 marker.options.icon = eval(marker.options.icon); 288 289 290 this.additionalMarker.push(marker.options); 291 }, 292 293 294 addAdditionalInfowWindows: function (infowindow) { 295 infowindow.options.uid = infowindow.linkToLayerUid 296 this.additionalInfoWindows.push(infowindow.options); 297 }, 298 299 /** 300 * Returns the additional infowindows 301 * @returns {Array} 302 */ 303 getAdditionalInfowWindows: function () { 304 return this.additionalInfoWindows; 305 }, 306 307 /** 308 * 309 * @returns {Array} 310 */ 311 getAddAdditionalMarkers: function () { 312 return this.additionalMarker; 313 }, 314 315 /** 316 * 317 * @returns {number} 318 */ 319 getLastPolylineIndex: function(){ 320 return this.lastPolyLineIndex; 321 }, 322 323 /** 324 * 325 * @param index 326 */ 327 setLastPolylineIndex: function (index) { 328 this.lastPolyLineIndex = index; 329 }, 330 331 getLastAdditionalMarkerPosition: function () { 332 return this.lastAdditionalMarkerPosition + 1; 333 }, 334 335 setLastAdditionalMarkerPosition: function (index) { 336 this.lastAdditionalMarkerPosition = index; 337 }, 338 339 /** 340 * Returns the currenct mapTypeId 341 * @returns {*} 342 */ 343 getMapTypeId: function () { 344 if(this.mapTypeId ){ 345 return this.mapTypeId; 346 } else { 347 return 'ROADMAP'; 348 } 349 } 350 351} 352function GMapHandler() { 353 'use strict'; 354 355 const self = this; 356 self.map = null; 357 self.isMobile = false; 358 self.infoWindow = null; 359 self.mapManager = null; 360 361 // Store currently displayed polylines to hide them later 362 self.activePolylines = []; 363 364 const winterStyle = [ /* Keep your original style array here (omitted for brevity) */ ]; 365 366 self.init = function () { 367 self.detectDevice(); 368 self.initMap(); 369 self.initClickEvents(); 370 }; 371 372 self.detectDevice = function () { 373 const ua = navigator.userAgent; 374 self.isMobile = /Android|iPhone|iPad|iPod|IEMobile|Opera Mini/i.test(ua); 375 }; 376 377 self.initMap = function () { 378 if (typeof googleMapTimetableConfig !== 'undefined') { 379 self.mapManager = new MapManager(googleMapTimetableConfig); 380 381 self.map = new google.maps.Map(document.getElementById("zbb-map"), { 382 ...self.mapManager.getMapOptions(), 383 mapTypeId: 'roadmap', 384 mapTypeControlOptions: { 385 mapTypeIds: ['roadmap', 'winter'] 386 } 387 }); 388 389 const styledMapType = new google.maps.StyledMapType(winterStyle, { name: 'Winter' }); 390 self.map.mapTypes.set('winter', styledMapType); 391 392 self.fillData(); 393 } 394 }; 395 396 self.initClickEvents = function () { 397 $('nav.filter ul li > span').on('click', function (e) { 398 e.preventDefault(); 399 $('nav.filter li').removeClass('active open'); 400 $(this).parent().addClass('active'); 401 }); 402 403 $('nav.filter .route-title').on('click', function (e) { 404 e.preventDefault(); 405 $(this).closest('ul').find('li').removeClass('active open'); 406 $(this).parent().addClass('active open'); 407 }); 408 409 $('#close-filter, #open-filter').on('click', function (e) { 410 e.preventDefault(); 411 $('#filter-content').toggleClass('open'); 412 }); 413 414 $('.load-activity').on('click', function (e) { 415 e.preventDefault(); 416 const url = $(this).data('url'); 417 418 $.ajax({ 419 url, 420 context: this, 421 success(data) { 422 self.mapManager.setAdditionalLayerOptions(data.layerOptions); 423 self.mapManager.setMapOptions(data.mapOptions); 424 self.updateMap(); 425 } 426 }); 427 }); 428 429 $('#map-switch input').on('change', function (e) { 430 e.preventDefault(); 431 432 $('#zbb-google').addClass('loading'); 433 $('#map-loader').show(); 434 435 const url = $(this).is(':checked') 436 ? $('#zbb-google').data('winter') 437 : $('#zbb-google').data('summer'); 438 439 const mapType = $(this).is(':checked') ? 'winter' : 'roadmap'; 440 self.map.setMapTypeId(mapType); 441 442 $.ajax({ 443 url, 444 cache: false, 445 success(data) { 446 const content = $('<div>' + data + '</div>'); 447 $("#zbb-google").html(content.find('#zbb-google').html()); 448 self.initClickEvents(); 449 450 if (typeof googleMapTimetableConfig !== 'undefined') { 451 self.mapManager.reset(googleMapTimetableConfig); 452 self.fillData(); 453 } 454 455 $('#zbb-google').removeClass('loading'); 456 $('#map-loader').hide(); 457 } 458 }); 459 }); 460 }; 461 462 self.fillData = function () { 463 // Hide previous polylines before drawing new ones
464 self.activePolylines.forEach(polyline => polyline.setMap(null)); 465 self.activePolylines = []; 466 467 const markers = self.mapManager.getMarkers(); 468 const polylines = self.mapManager.getPolylines(); 469 const infoWindows = self.mapManager.getInfoWindows(); 470 471 markers.forEach((markerData, index) => { 472 const marker = new google.maps.Marker({ 473 ...markerData, 474 map: self.map 475 }); 476 477 if (self.mapManager.getInfoWindowIndexByUid(markerData.uid)) { 478 const infowindow = new google.maps.InfoWindow(infoWindows[self.mapManager.getInfoWindowIndexByUid(markerData.uid)]); 479 480 marker.addListener("click", () => { 481 if (self.infoWindow) self.infoWindow.close(); 482 self.infoWindow = infowindow; 483 self.infoWindow.open(self.map, marker); 484 }); 485 } 486 }); 487 488 polylines.forEach(polylineData => { 489 const polyline = new google.maps.Polyline({ 490 ...polylineData, 491 map: self.map 492 }); 493 self.activePolylines.push(polyline); 494 }); 495 }; 496 497 self.updateMap = function () { 498 // Hide previous polylines before drawing new ones 499 self.activePolylines.forEach(polyline => polyline.setMap(null)); 500 self.activePolylines = []; 501 502 // Redraw polylines 503 const polylines = self.mapManager.getPolylines(); 504 polylines.forEach(polylineData => { 505 const polyline = new google.maps.Polyline({ 506 ...polylineData, 507 map: self.map 508 }); 509 self.activePolylines.push(polyline); 510 }); 511 512 // Redraw additional markers 513 const markers = self.mapManager.getAddAdditionalMarkers(); 514 const infoWindows = self.mapManager.getAdditionalInfowWindows(); 515 516 markers.forEach((markerData, index) => { 517 const marker = new google.maps.Marker({ 518 ...markerData, 519 map: self.map 520 }); 521 522 if (self.mapManager.getInfoWindowIndexByUid(markerData.uid)) { 523 const infowindow = new google.maps.InfoWindow(infoWindows[self.mapManager.getAdditionalInfoWindowIndexByUid(markerData.uid)]); 524 525 marker.addListener("click", () => { 526 if (self.infoWindow) self.infoWindow.close(); 527 self.infoWindow = infowindow; 528 self.infoWindow.open(self.map, marker); 529 }); 530 } 531 }); 532 533 // Apply any updated map options 534 self.map.setOptions(self.mapManager.getUpdateMapOptions()); 535 }; 536} 537 538var zbbGmap; 539$(document).ready(function () { 540 zbbGmap = new GMapHandler(); 541 zbbGmap.init(); 542});
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.