PageSourceSearch

https://www.mssg.ch/cache-buster-1716982323/bundles/aufwinddraft/js/frontend/draft-googleMaps.js

js mssg.ch collected 2026-10-07 08:21:14 UTC 5,592 bytes, 172 lines download raw bytes

1/*
2        __           __                                ___       _ __        __
3   ____/ /___ ______/ /_  _________  ____ ___     ____/ (_)___ _(_) /_____ _/ /
4  / __  / __ `/ ___/ __ \/ ___/ __ \/ __ `__ \   / __  / / __ `/ / __/ __ `/ /
5 / /_/ / /_/ / /__/ / / / /__/ /_/ / / / / / /  / /_/ / / /_/ / / /_/ /_/ / /
6 \__,_/\__,_/\___/_/ /_/\___/\____/_/ /_/ /_/   \__,_/_/\__, /_/\__/\__,_/_/
7                                                       /____/
8 copyright © dachcom digital
9
10 */
11
12var AufwindDraftGoogleMaps = (function () {
13
14    'use strict';
15
16    var self = {
17
18        $doc: $ !== undefined ? $(document) : null,
19
20        isBusy : false,
21
22        editMode : false,
23
24        init: function() {
25
26            self.editMode = typeof _PIMCORE_EDITMODE !== 'undefined' && _PIMCORE_EDITMODE === true;
27
28            self.startSystem();
29
30        },
31
32        startSystem: function() {
33
34            this.setupGoogleMaps();
35
36        },
37
38        setupGoogleMaps: function() {
39
40            var $maps = $('.draft-googlemap'),
41            
42                //internal callback 1
43                isValidLocation = function(location) {
44                    
45                    return location.hasOwnProperty('lat') && location.hasOwnProperty('lng') && !isNaN(location.lat) && !isNaN(location.lng);
46                },
47
48                //internal callback 2
49                addMarker = function(map, location, markerIcon, showInfoWindowOnLoad) {
50
51                    var marker, infoWindow;
52
53                    if ( isValidLocation(location) ) {
54                            marker = new google.maps.Marker({
55                            position: new google.maps.LatLng (location.lat, location.lng),
56                            map: map,
57                            title: location.title,
58                            icon: markerIcon,
59                            contentLoaded: false
60                        });
61
62                        infoWindow = new google.maps.InfoWindow({
63                            content: '<div class="info-window"><div class="loading"></div></div>'
64                        });
65
66                        marker.addListener('click', function() {
67
68                            infoWindow.open(map, marker);
69
70                            if(marker.contentLoaded === false) {
71                                $.ajax({
72
73                                    url: '/draft/ajax/gm-info-window',
74                                    method: 'POST',
75                                    data: {
76                                        mapParams : location,
77                                        language: $('html').attr('lang')
78                                    },
79                                    complete: function(result) {
80                                        marker.contentLoaded = true;
81                                        infoWindow.setContent(result.responseText);
82                                        map.setCenter(marker.getPosition());
83                                    }
84
85                                });
86
87                            }
88
89                        });
90
91                        if(showInfoWindowOnLoad === true) {
92                            google.maps.event.trigger(marker, 'click');
93                        }
94                    }
95
96                };
97               
98            $maps.each(function() {
99
100                var $map = $(this),
101                    map, latLngBounds, listener,
102                    locations = $map.data('locations') || [],
103                    mapStyleUrl = $map.data('mapstyleurl'),
104                    markerIcon = $map.data('markericon'),
105                    showInfoWindowOnLoad = $map.data('show-info-window-on-load') === 1,
106                    mapOptions = {
107                        center: new google.maps.LatLng (52.520008, 13.404954)
108                    };
109
110                $.each($map.data(), function(name, value) {
111
112                    if ( name.substring(0,9) === 'mapoption' ) {
113                        name = name.replace('mapoption', '');
114                        name = name.charAt(0).toLowerCase() + name.slice(1);
115
116                        mapOptions[name] = value;
117                    }
118
119                });
120
121                map = new google.maps.Map($map.get(0), mapOptions);
122                latLngBounds = new google.maps.LatLngBounds();
123
124                if ( typeof mapStyleUrl === 'string' ) {
125
126                    $.getJSON(mapStyleUrl).done(function(data) {
127                        map.set('styles', data);
128                    });
129
130                }
131
132                if ( locations.length > 0 ) {
133
134                    $.each(locations, function(i, location) {
135
136                        if ( isValidLocation(location) ) {
137                            latLngBounds.extend( new google.maps.LatLng(location.lat, location.lng) );
138                            addMarker(map, location, markerIcon, showInfoWindowOnLoad);
139                        }
140
141                    });
142
143                    map.fitBounds( latLngBounds );
144
145                    listener = google.maps.event.addListener(map, 'idle', function() {
146                        var zoom = (typeof mapOptions.zoom === 'number' && (mapOptions.zoom % 1) === 0) ? mapOptions.zoom : 17;
147                        map.setZoom(zoom);
148                        google.maps.event.removeListener(listener);
149                    });
150
151                }
152
153            });
154
155        }
156
157    };
158
159    return {
160        init: self.init
161    };
162
163})();
164
165if( $ !== undefined) {
166
167    $(function() {
168        'use strict';
169        AufwindDraftGoogleMaps.init();
170    });
171
172}

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.