| 1 |  |  | /* globals google */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Concatenates default settings and user-defined settings to one object for use in maps object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @param  {object} location    [object containing latitude, longitude and zoom value] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @param  {object} mapSettings [google maps api configuration object] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @param  {object} mapStyles   [google maps styling configuration object] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @return {object}             [concatenated object with all options] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | export function assignMapsSettings (location, mapSettings, mapStyles) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |   Object.assign(mapSettings, { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     scrollwheel: false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     styles: mapStyles, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     center: { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |       lat: location.lat, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |       lng: location.lng | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     }, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     zoom: location.zoom | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |   }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |   return mapSettings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * Concatenates default settings and user-defined settings to one object for use in marker object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @param  {object} location        [object containing lat and lang value] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @param  {object} markerSettings  [google maps api marker configuration object] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @param  {object} map             [google maps object] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * @return {object}                 [concatenated object with all options] | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 30 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | export function assignMarkerSettings (location, markerSettings, map) { | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |   Object.assign(markerSettings, { | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     position: { | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |       lat: location.lat, | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |       lng: location.lng | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |     }, | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     map: map | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |   }) | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |   return markerSettings | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  * Adds a icon object to the passed markerSettings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  * @param {object} markerSettings   Contains the already set settings for this type of marker | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  * @param {string} iconUrl          Contains the absolute URL to the marker icon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  * @param {Number} [scaledSizeX=16] Scaled width for the new icon | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  * @param {Number} [scaledSizeY=16] Scaled height for the new icon | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | export function setMarkerIcon (markerSettings, iconUrl, scaledSizeX = 16, scaledSizeY = 16) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |   Object.assign(markerSettings, { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     'icon': { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |       'url': iconUrl, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |       'scaledSize': new google.maps.Size(scaledSizeX, scaledSizeY), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |       'origin': new google.maps.Point(0, 0), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |       'anchor': new google.maps.Point(scaledSizeX / 2, scaledSizeY / 2) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |   }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |   return markerSettings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  * Adds a Google Maps Info Window to a marker | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  * @param {string} content  [HTML content for the marker] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  * @param {object} marker   [Google maps marker object] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  * @param {object} map      [Google maps map object] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  * @return {object}         [Google maps info window object] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | export function addInfoWindowToMarker (content, marker, map) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |   const infoWindow = new google.maps.InfoWindow({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     content: content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |   }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |   marker.addListener('click', () => { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     infoWindow.open(map, marker) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |   }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |   return infoWindow | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  * Resets a google map to a certain location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  * @param {object} location [object containing lat and lang values] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  * @param {object} map      [google maps object] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | export function resetMap (location, map) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |   map.setCenter({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     lat: location.lat, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     lng: location.lng | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |   }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |   map.setZoom(location.zoom) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  * Returns location of a container containing lat, lng and zoom values in data-attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  * @param  {object} $container [jQuery object of the container] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  * @return {object}            [object containing lat, lng and zoom values] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | export function getLocationFromContainer ($container) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |   return { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     'lat': parseFloat($container.data('lat')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     'lng': parseFloat($container.data('lng')), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     'zoom': parseFloat($container.data('zoom')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |   } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 107 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 108 |  |  |  |