1/** 2 * Script in /templates/TrackDetails-original.html 3 * Script in /partials/maps/GoogleMap.html 4 * Script in /partials/details/TrackMap.html 5 */ 6 7this.swemaps = {}; 8 9(function (exports) { 10 let __self, __canvasID; 11 12 exports.create = function (self, canvasID) { 13 if (!window.swe.isGMapLoaded()) { 14 __self = self; 15 __canvasID = canvasID; 16 return; 17 } 18 19 if (typeof canvasID !== 'string') return self; 20 21 let mapCanvas = document.getElementById(canvasID); 22 23 if (!mapCanvas) return self; 24 25 self.__config = { 26 canvasID: null, 27 map: null, 28 markers: [], 29 marker_icon: '', 30 line_start_icon: null, 31 line_end_icon: null, 32 lines: [], 33 circles: [], 34 bounds: null, 35 infoWindow: null, 36 marker_clusterer: null, 37 options: { 38 center: {lat: 51.4409934, lng: 6.945979}, 39 zoom: 8, 40 zoomControl: true, 41 mapTypeControl: true, 42 scaleControl: true, 43 streetViewControl: true, 44 rotateControl: true, 45 scrollwheel: false, 46 draggable: window.innerWidth > 1024, 47 mapTypeId: google.maps.MapTypeId.TERRAIN, 48 //mapTypeControlOptions: { 49 // mapTypeIds: ['grey'] 50 //} 51 }, 52 styles: [ 53 { 54 key: 'grey', 55 label: 'Map', 56 config: [ 57 { 58 "featureType": "landscape", 59 "stylers": [ 60 {"color": "#f9f9f9"} 61 ] 62 }, 63 { 64 "featureType": "road.highway", 65 "stylers": [ 66 {"color": "#eaeaea"} 67 ] 68 }, 69 { 70 "featureType": "transit", 71 "stylers": [ 72 {"color": "#eaeaea"} 73 ] 74 }, 75 { 76 "featureType": "water", 77 "stylers": [ 78 {"color": "#eaeaea"} 79 ] 80 }, 81 { 82 "featureType": "poi", 83 "elementType": "geometry", 84 "stylers": [ 85 {"color": "#eaeaea"} 86 ] 87 }, 88 { 89 "elementType": "labels.text.fill", 90 "stylers": [ 91 {"color": "#808080"} 92 ] 93 } 94 ] 95 } 96 ], 97 }; 98 99 self.get_meters_per_pixel = function (lat) { 100 if (!self.__config.map) return 0; 101 102 return 156543.03392 * Math.cos(lat * Math.PI / 180) / Math.pow(2, self.__config.map.getZoom()); 103 }; 104 105 self.focus = function () { 106 let canvas = document.getElementById(self.__config.canvasID); 107 108 if (canvas) swescroll.to_element(canvas); 109 }; 110 111 self.reset_bounds = function () { 112 if (self.__config.map) self.__config.bounds = new google.maps.LatLngBounds(); 113 }; 114 115 self.fit_markers_bounds = function () { 116 if (!self.__config.map) return; 117 118 if (self.__config.bounds === null) self.__config.bounds = new google.maps.LatLngBounds(); 119 120 if (self.__config.markers.length >= 1) { 121 for (let i = 0; i < self.__config.markers.length; i += 1) { 122 let marker = self.__config.markers[i], 123 position = new google.maps.LatLng(marker.position.lat(), marker.position.lng()); 124 125 self.__config.bounds.extend(position); 126 } 127 } 128 129 //self.__config.map.fitBounds(self.__config.bounds); 130 }; 131 132 self.fit_lines_bounds = function () { 133 if (!self.__config.map) return; 134 135 if (self.__config.bounds === null) self.__config.bounds = new google.maps.LatLngBounds(); 136 137 for (let i = 0; i < self.__config.lines.length; i += 1) { 138 let line = self.__config.lines[i], 139 coords = line.getPath(); 140 141 for (let j = 0; j < coords.length; j += 1) { 142 let coord = coords.getAt(j), 143 position = new google.maps.LatLng(coord.lat(), coord.lng()); 144 145 self.__config.bounds.extend(position); 146 } 147 } 148 149 //self.__config.map.fitBounds(self.__config.bounds); 150 }; 151 152 self.draw_bounding_box = function () { 153 if (!self.__config.map || !self.__config.bounds) return; 154 155 let rectangle = new google.maps.Rectangle({
156 strokeColor: '#FF0000', 157 strokeOpacity: 0.8, 158 strokeWeight: 2, 159 fillColor: '#FF0000', 160 fillOpacity: 0.35, 161 map: self.__config.map, 162 }); 163 164 rectangle.setBounds(self.__config.bounds); 165 }; 166 167 self.update_viewport = function () { 168 if (!self.__config.map || !self.__config.bounds) return; 169 170 self.reset_bounds(); 171 self.fit_markers_bounds(); 172 self.fit_lines_bounds(); 173 self.__config.map.setCenter(self.__config.bounds.getCenter()); 174 self.__config.map.fitBounds(self.__config.bounds); 175 //self.draw_bounding_box(); 176 }; 177 178 self.remove_elements = function () { 179 self.remove_lines(); 180 self.remove_markers(); 181 self.remove_circles(); 182 self.reset_bounds(); 183 }; 184 185 self.set_marker_icon = function (icon) { 186 self.__config.marker_icon = icon; 187 }; 188 189 self.set_line_start_icon = function (icon) { 190 self.__config.line_start_icon = icon; 191 }; 192 193 self.set_line_end_icon = function (icon) { 194 self.__config.line_end_icon = icon; 195 }; 196 197 self.add_marker = function (label, lat, lng, onClickHtml) { 198 if (!self.__config.map) return; 199 200 let marker = new google.maps.Marker({ 201 position: new google.maps.LatLng(lat, lng), 202 icon: self.__config.marker_icon, 203 //title: label, 204 //label: label, //wird im Marker angezeigt 205 map: self.__config.map 206 }); 207 208 if (onClickHtml) { 209 google.maps.event.addListener(marker, 'click', function () { 210 self.__config.infoWindow.setContent(onClickHtml); 211 self.__config.infoWindow.open(self.__config.map, marker); 212 }); 213 } 214 215 self.__config.markers.push(marker); 216 return marker; 217 }; 218 219 self.remove_markers = function () { 220 for (let i = 0; i < self.__config.markers.length; i += 1) { 221 let marker = self.__config.markers[i]; 222 marker.setMap(null); 223 } 224 225 self.__config.markers = []; 226 }; 227 228 self.add_line = function (coords, style, fclick) { 229 if (!self.__config.map) return null; 230 231 let line_icons = []; 232 233 if (self.__config.line_start_icon !== null) { 234 line_icons.push({ 235 icon: self.__config.line_start_icon, 236 offset: '0%' 237 }); 238 } 239 240 if (self.__config.line_end_icon !== null) { 241 line_icons.push({ 242 icon: self.__config.line_end_icon, 243 offset: '100%' 244 }); 245 } 246 247 let line = new google.maps.Polyline({ 248 path: coords, 249 icons: line_icons, 250 map: self.__config.map, 251 //geodesic: true, 252 strokeColor: style.stroke_color, 253 strokeOpacity: style.stroke_opacity, 254 strokeWeight: style.stroke_weight 255 }); 256 self.__config.lines.push(line); 257 258 if (typeof fclick === 'function') { 259 google.maps.event.addListener(line, 'click', fclick); 260 } 261 262 return line; 263 }; 264 265 self.remove_lines = function () { 266 for (let i = 0; i < self.__config.lines.length; i += 1) { 267 let line = self.__config.lines[i]; 268 line.setMap(null); 269 } 270 271 self.__config.lines = []; 272 }; 273 274 self.add_circle = function (centerLat, centerLng, radius, style) { 275 if (!self.__config.map) return null; 276 277 let circle = new google.maps.Circle({ 278 strokeColor: style.stroke_color, 279 strokeOpacity: style.stroke_opacity, 280 strokeWeight: style.stroke_weight, 281 fillColor: style.fill_color, 282 fillOpacity: style.fill_opacity, 283 map: self.__config.map, 284 center: {lat: centerLat, lng: centerLng}, 285 radius: radius 286 }); 287 self.__config.circles.push(circle); 288 289 return circle; 290 }; 291 292 self.remove_circles = function () { 293 for (let i = 0; i < self.__config.circles.length; i += 1) { 294 let circle = self.__config.circles[i]; 295 circle.setMap(null); 296 } 297 298 self.__config.circles = []; 299 }; 300 301 self.show_marker_clusters = function () { 302 if (!self.__config.map || typeof MarkerClusterer !== 'function') return; 303 304 let _markers = []; 305 306 for (let i = 0; i < self.__config.markers.length; i += 1) { 307 let marker = self.__config.markers[i]; 308 _markers.push(marker); 309 } 310 311 self.__config.marker_clusterer = new MarkerClusterer(self.__config.map, _markers); 312 }; 313 314 // =========================================================================== 315 316 let __is_window_global = function (ns) {
317 for (let name in window) { 318 if (name === ns) return true; 319 } 320 321 return false; 322 }; 323 324 let __check = function () { 325 let required = ['swescroll', 'swe'], 326 not_found = []; 327 328 for (let i = 0; i < required.length; i += 1) { 329 if (!__is_window_global(required[i])) not_found.push(required[i]); 330 } 331 332 if (not_found.length > 0) { 333 throw '[swemaps.js] NAMESPACES NOT FOUND: ' + not_found.join(', '); 334 } 335 336 return self; 337 }; 338 339 // =========================================================================== 340 341 __check(); 342 343 if (canvasID) { 344 self.__config.canvasID = canvasID; 345 let mapCanvas = document.getElementById(canvasID); 346 347 if (mapCanvas) { 348 let map = new google.maps.Map(mapCanvas, self.__config.options); 349 /* 350 for (let i = 0; i < self.__config.styles.length; i += 1) { 351 let style = self.__config.styles[i], 352 mapType = new google.maps.StyledMapType(style.config, {name: style.label}); 353 354 map.mapTypes.set(style.key, mapType); 355 map.setMapTypeId(style.key); 356 } 357 */ 358 window.addEventListener('resize', function () { 359 let center = map.getCenter(); 360 361 google.maps.event.trigger(map, "resize"); 362 map.setCenter(center); 363 map.set("draggable", window.innerWidth > 1024); 364 }); 365 366 self.__config.map = map; 367 self.__config.infoWindow = new google.maps.InfoWindow({content: ''}); 368 } 369 } 370 371 return self; 372 }; 373 374 exports.setup = function() { 375 document.addEventListener(swe.cookieBannerArgs.event, function (event) { 376 exports.create(__self, __canvasID); 377 }); 378 }; 379 380})(this.swemaps); 381 382document.addEventListener('DOMContentLoaded', function(event) { 383 try { 384 window.swemaps.setup(); 385 } catch (e) { 386 console.log(e); 387 } 388}); 389 390// this.swemaps = { 391// 392// create: function (self, canvasID) { 393// 394// if (typeof canvasID !== 'string') { 395// return self; 396// } 397// var mapCanvas = document.getElementById(canvasID); 398// 399// if (!mapCanvas) { 400// return self; 401// } 402// 403// self.__config = { 404// canvasID: null, 405// map: null, 406// markers: [],
407// marker_icon: '', 408// line_start_icon: null, 409// line_end_icon: null, 410// lines: [], 411// circles: [], 412// bounds: null, 413// infoWindow: null, 414// marker_clusterer: null, 415// options: { 416// center: {lat: 51.4409934, lng: 6.945979}, 417// zoom: 8, 418// zoomControl: true, 419// mapTypeControl: true, 420// scaleControl: true, 421// streetViewControl: true, 422// rotateControl: true, 423// scrollwheel: false, 424// draggable: window.innerWidth > 1024 ? true : false, 425// mapTypeId: google.maps.MapTypeId.TERRAIN, 426// //mapTypeControlOptions: { 427// // mapTypeIds: ['grey'] 428// //} 429// }, 430// styles: [ 431// { 432// key: 'grey', 433// label: 'Map', 434// config: [ 435// { 436// "featureType": "landscape", 437// "stylers": [ 438// {"color": "#f9f9f9"} 439// ] 440// }, 441// { 442// "featureType": "road.highway", 443// "stylers": [ 444// {"color": "#eaeaea"} 445// ] 446// }, 447// { 448// "featureType": "transit", 449// "stylers": [ 450// {"color": "#eaeaea"} 451// ] 452// }, 453// { 454// "featureType": "water", 455// "stylers": [ 456// {"color": "#eaeaea"} 457// ] 458// }, 459// { 460// "featureType": "poi", 461// "elementType": "geometry", 462// "stylers": [ 463// {"color": "#eaeaea"} 464// ] 465// }, 466// { 467// "elementType": "labels.text.fill", 468// "stylers": [ 469// {"color": "#808080"} 470// ] 471// } 472// ] 473// } 474// ], 475// }; 476// 477// self.get_meters_per_pixel = function (lat) { 478// if (self.__config.map) { 479// return 156543.03392 * Math.cos(lat * Math.PI / 180) / Math.pow(2, self.__config.map.getZoom()); 480// } 481// return 0; 482// }; 483// 484// self.focus = function () { 485// var canvas = document.getElementById(self.__config.canvasID); 486// 487// if (canvas) { 488// swescroll.to_element(canvas); 489// } 490// }; 491// 492// self.reset_bounds = function () { 493// if (self.__config.map) { 494// self.__config.bounds = new google.maps.LatLngBounds(); 495// } 496// }; 497// 498// self.fit_markers_bounds = function () { 499// if (self.__config.map) { 500// if (self.__config.bounds === null) { 501// self.__config.bounds = new google.maps.LatLngBounds(); 502// } 503// if (self.__config.markers.length >= 1) { 504// for (var i = 0; i < self.__config.markers.length; ++i) { 505// var marker = self.__config.markers[i]; 506// var position = new google.maps.LatLng(marker.position.lat(), marker.position.lng()); 507// self.__config.bounds.extend(position); 508// } 509// } 510// //self.__config.map.fitBounds(self.__config.bounds); 511// } 512// }; 513// 514// self.fit_lines_bounds = function () { 515// if (self.__config.map) { 516// if (self.__config.bounds === null) { 517// self.__config.bounds = new google.maps.LatLngBounds(); 518// } 519// for (var i = 0; i < self.__config.lines.length; ++i) { 520// var line = self.__config.lines[i]; 521// var coords = line.getPath(); 522// 523// for (var j = 0; j < coords.length; ++j) { 524// var coord = coords.getAt(j) 525// var position = new google.maps.LatLng(coord.lat(), coord.lng()); 526// self.__config.bounds.extend(position); 527// } 528// } 529// //self.__config.map.fitBounds(self.__config.bounds); 530// } 531// }; 532// 533// self.draw_bounding_box = function () { 534// if (self.__config.map && self.__config.bounds) { 535// var rectangle = new google.maps.Rectangle({ 536// strokeColor: '#FF0000', 537// strokeOpacity: 0.8, 538// strokeWeight: 2,
539// fillColor: '#FF0000', 540// fillOpacity: 0.35, 541// map: self.__config.map, 542// }); 543// rectangle.setBounds(self.__config.bounds); 544// } 545// }; 546// 547// self.update_viewport = function () { 548// if (self.__config.map && self.__config.bounds) { 549// self.reset_bounds(); 550// self.fit_markers_bounds(); 551// self.fit_lines_bounds(); 552// self.__config.map.setCenter(self.__config.bounds.getCenter()); 553// self.__config.map.fitBounds(self.__config.bounds); 554// //self.draw_bounding_box(); 555// } 556// } 557// 558// self.remove_elements = function () { 559// self.remove_lines(); 560// self.remove_markers(); 561// self.remove_circles(); 562// self.reset_bounds(); 563// }; 564// 565// self.set_marker_icon = function (icon) { 566// self.__config.marker_icon = icon; 567// }; 568// 569// self.set_line_start_icon = function (icon) { 570// self.__config.line_start_icon = icon; 571// }; 572// 573// self.set_line_end_icon = function (icon) { 574// self.__config.line_end_icon = icon; 575// }; 576// 577// self.add_marker = function (label, lat, lng, onClickHtml) { 578// if (self.__config.map) { 579// var marker = new google.maps.Marker({ 580// position: new google.maps.LatLng(lat, lng), 581// icon: self.__config.marker_icon, 582// //title: label, 583// //label: label, //wird im Marker angezeigt 584// map: self.__config.map 585// }); 586// if (onClickHtml) { 587// google.maps.event.addListener(marker, 'click', function () { 588// self.__config.infoWindow.setContent(onClickHtml); 589// self.__config.infoWindow.open(self.__config.map, marker); 590// }); 591// } 592// self.__config.markers.push(marker); 593// return marker; 594// } 595// }; 596// 597// self.remove_markers = function () { 598// for (var i = 0; i < self.__config.markers.length; ++i) { 599// var marker = self.__config.markers[i]; 600// marker.setMap(null); 601// } 602// self.__config.markers = []; 603// }; 604// 605// self.add_line = function (coords, style, fclick) { 606// if (self.__config.map) { 607// var line_icons = []; 608// 609// if (self.__config.line_start_icon !== null) { 610// line_icons.push({ 611// icon: self.__config.line_start_icon, 612// offset: '0%' 613// }); 614// } 615// if (self.__config.line_end_icon !== null) { 616// line_icons.push({ 617// icon: self.__config.line_end_icon, 618// offset: '100%' 619// }); 620// } 621// var line = new google.maps.Polyline({ 622// path: coords, 623// icons: line_icons, 624// map: self.__config.map, 625// //geodesic: true, 626// strokeColor: style.stroke_color, 627// strokeOpacity: style.stroke_opacity, 628// strokeWeight: style.stroke_weight 629// }); 630// self.__config.lines.push(line); 631// 632// if (typeof fclick === 'function') { 633// google.maps.event.addListener(line, 'click', fclick); 634// } 635// return line; 636// } 637// return null; 638// }; 639// 640// self.remove_lines = function () { 641// for (var i = 0; i < self.__config.lines.length; ++i) { 642// var line = self.__config.lines[i]; 643// line.setMap(null); 644// } 645// self.__config.lines = []; 646// }; 647// 648// self.add_circle = function (centerLat, centerLng, radius, style) { 649// if (self.__config.map) { 650// var circle = new google.maps.Circle({ 651// strokeColor: style.stroke_color, 652// strokeOpacity: style.stroke_opacity, 653// strokeWeight: style.stroke_weight, 654// fillColor: style.fill_color, 655// fillOpacity: style.fill_opacity, 656// map: self.__config.map, 657// center: {lat: centerLat, lng: centerLng}, 658// radius: radius 659// }); 660// self.__config.circles.push(circle); 661// return circle; 662// } 663// return null; 664// }; 665// 666// self.remove_circles = function () { 667// for (var i = 0; i < self.__config.circles.length; ++i) { 668// var circle = self.__config.circles[i]; 669// circle.setMap(null); 670// } 671// self.__config.circles = []; 672// }; 673//
674// self.show_marker_clusters = function () { 675// if (self.__config.map) { 676// if (typeof MarkerClusterer === 'function') { 677// var _markers = []; 678// 679// for (var i = 0; i < self.__config.markers.length; ++i) { 680// var marker = self.__config.markers[i]; 681// _markers.push(marker); 682// } 683// self.__config.marker_clusterer = new MarkerClusterer(self.__config.map, _markers); 684// } 685// } 686// }; 687// 688// // =========================================================================== 689// 690// var __is_window_global = function (ns) { 691// for (var name in window) { 692// if (name === ns) { 693// return true; 694// } 695// } 696// return false; 697// }; 698// 699// var __check = function () { 700// var required = ['swescroll']; 701// var not_found = []; 702// 703// for (var i = 0; i < required.length; ++i) { 704// if (!__is_window_global(required[i])) { 705// not_found.push(required[i]); 706// } 707// } 708// if (not_found.length > 0) { 709// throw '[swemaps.js] NAMESPACES NOT FOUND: ' + not_found.join(', '); 710// } 711// return self; 712// }; 713// 714// // =========================================================================== 715// 716// __check(); 717// 718// if (canvasID) { 719// self.__config.canvasID = canvasID; 720// var mapCanvas = document.getElementById(canvasID); 721// 722// if (mapCanvas) { 723// var map = new google.maps.Map(mapCanvas, self.__config.options); 724// /* 725// for(var i = 0; i < self.__config.styles.length; i++) { 726// var style = self.__config.styles[i]; 727// var mapType = new google.maps.StyledMapType(style.config, {name: style.label}); 728// map.mapTypes.set(style.key, mapType); 729// map.setMapTypeId(style.key); 730// } 731// */ 732// google.maps.event.addDomListener(window, "resize", function () { 733// var center = map.getCenter(); 734// google.maps.event.trigger(map, "resize"); 735// map.setCenter(center); 736// map.set("draggable", window.innerWidth > 1024 ? true : false); 737// }); 738// self.__config.map = map; 739// self.__config.infoWindow = new google.maps.InfoWindow({content: ''}); 740// } 741// } 742// return self; 743// } 744// };
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.