1(function() { 2 (function() { 3 var $, $modules, BASE_URL, LANDMARK_FILTERS, MINIMUM_BOUNDS_DELTA, NO_VISIBILITY_STYLER, STRING_BOOLEANS, createMarkerIcon, createStyles, getMapBoundsfromLocations, loadGoogleMaps, mapsPromise, plotLocations, populate, previousMapCenter, rehydrate; 4 $ = this.jQuery; 5 mapsPromise = null; 6 previousMapCenter = null; 7 MINIMUM_BOUNDS_DELTA = 0.005; 8 NO_VISIBILITY_STYLER = [ 9 { 10 visibility: "off" 11 } 12 ]; 13 BASE_URL = _4ORMAT_DATA.paths.app_base; 14 if (window.location.port) { 15 BASE_URL += ":" + window.location.port; 16 } 17 STRING_BOOLEANS = { 18 "false": false, 19 "true": true 20 }; 21 LANDMARK_FILTERS = [ 22 { 23 "featureType": "administrative", 24 "elementType": "geometry" 25 }, { 26 "featureType": "poi" 27 }, { 28 "featureType": "road", 29 "elementType": "labels.icon" 30 }, { 31 "featureType": "transit" 32 } 33 ]; 34 populate = (function(_this) { 35 return function($module) { 36 var $mapWrapper; 37 $mapWrapper = $module.find('.map-wrapper'); 38 $mapWrapper.addClass('loading'); 39 return loadGoogleMaps().then(function() { 40 return rehydrate($module); 41 }); 42 }; 43 })(this); 44 rehydrate = (function(_this) { 45 return function($module) { 46 var $mapWrapper, defaultMapOptions, locations, map, mapLoadListener, mapOptions, mapStyles, mapThemeID, markerIcon, markerThemeID, supportsLandmarks, supportsZoomPan; 47 locations = $module.data('locations') || []; 48 $mapWrapper = $module.find('.map-wrapper'); 49 $module.toggleClass('empty', !locations.length); 50 if (!locations.length) { 51 $mapWrapper.removeClass('loading'); 52 return; 53 } 54 mapOptions = $module.data('map_options'); 55 defaultMapOptions = $module.data('default_map_options'); 56 mapOptions = $.extend(defaultMapOptions, mapOptions); 57 mapThemeID = mapOptions.map_theme; 58 supportsLandmarks = STRING_BOOLEANS[mapOptions.supports_landmarks]; 59 mapStyles = createStyles(mapThemeID, supportsLandmarks); 60 markerThemeID = mapOptions.marker_theme; 61 markerIcon = createMarkerIcon(markerThemeID); 62 supportsZoomPan = STRING_BOOLEANS[mapOptions.supports_zoom_pan]; 63 map = plotLocations($mapWrapper[0], locations, mapStyles, markerIcon, supportsZoomPan); 64 return mapLoadListener = map.addListener('tilesloaded', function() { 65 google.maps.event.removeListener(mapLoadListener); 66 return $mapWrapper.removeClass('loading'); 67 }); 68 }; 69 })(this); 70 createStyles = (function(_this) { 71 return function(themeID, supportsLandmarks) { 72 var MAP_THEMES, styles; 73 MAP_THEMES = $.extend(true, {}, window._4ORMAT.MAP_THEMES); 74 styles = MAP_THEMES[themeID] || []; 75 if (supportsLandmarks) { 76 return styles; 77 } 78 LANDMARK_FILTERS.forEach(function(filter) { 79 var featureStyle, newStyle; 80 featureStyle = styles.find(function(style) { 81 return style.featureType === filter.featureType && (style.elementType === filter.elementType || !filter.elementType); 82 }); 83 if (featureStyle) { 84 return featureStyle.stylers = NO_VISIBILITY_STYLER; 85 } else { 86 newStyle = { 87 stylers: NO_VISIBILITY_STYLER, 88 elementType: filter.elementType 89 }; 90 if (filter.featureType) { 91 newStyle.featureType = filter.featureType; 92 } 93 return styles.push(newStyle); 94 } 95 }); 96 return styles; 97 }; 98 })(this); 99 createMarkerIcon = function(themeID) { 100 var icon, markerStyle; 101 markerStyle = window._4ORMAT.MARKER_THEMES[themeID]; 102 if (markerStyle != null) { 103 icon = { 104 url: BASE_URL + "/static/theme_api/map_embeds/markers/" + themeID + ".svg", 105 anchor: new google.maps.Point(markerStyle.offset.x, markerStyle.offset.y), 106 scaledSize: new google.maps.Size(50, 50), 107 size: new google.maps.Size(50, 50) 108 }; 109 } else { 110 icon = null; 111 } 112 return icon; 113 }; 114 plotLocations = (function(_this) { 115 return function($e, locations, mapStyles, markerIcon, supportsZoomPan) { 116 var bounds, infoWindow, location, map, markers; 117 map = new google.maps.Map($e, { 118 fullscreenControl: false, 119 streetViewControl: false, 120 zoomControl: supportsZoomPan, 121 gestureHandling: supportsZoomPan ? 'auto' : 'none', 122 mapTypeControl: false, 123 styles: mapStyles 124 }); 125 locations = (function() { 126 var i, len, results; 127 results = []; 128 for (i = 0, len = locations.length; i < len; i++) { 129 location = locations[i]; 130 if (location.coordinates != null) { 131 results.push(location); 132 } 133 } 134 return results; 135 })(); 136 bounds = getMapBoundsfromLocations(locations); 137 map.fitBounds(bounds); 138 infoWindow = new google.maps.InfoWindow(); 139 google.maps.event.addListener(infoWindow, 'closeclick', function() { 140 if (!supportsZoomPan) { 141 return map.panTo(previousMapCenter); 142 } 143 }); 144 markers = locations.forEach(function(location) { 145 var marker; 146 if (location.coordinates == null) { 147 return; 148 } 149 marker = new google.maps.Marker({ 150 position: location.coordinates, 151 icon: markerIcon, 152 map: map 153 }); 154 return marker.addListener('click', function() { 155 var address, label; 156 label = location.label, address = location.address; 157 previousMapCenter = map.getCenter(); 158 infoWindow.setContent("<div class='location-info'> <h2 class='location-info__label'>" + (label || '') + "</h2> <p class='location-info__address-1'>" + address + "</p> <p class='location-info__map-link'> <a href='https://www.google.com/maps/search/?api=1&query=" + (encodeURI(address)) + "' target='_blank'>View larger map</a> </p> </div>"); 159 infoWindow.open(map, marker); 160 return map.panTo(marker.getPosition()); 161 }); 162 }); 163 return map; 164 }; 165 })(this); 166 loadGoogleMaps = function() { 167 var ref, ref1, ref2; 168 if (mapsPromise != null) { 169 return mapsPromise; 170 } 171 mapsPromise = $.Deferred(); 172 if (((ref = window.google) != null ? ref.maps : void 0) != null) { 173 return mapsPromise.resolve(); 174 } 175 if (((ref1 = window.parent) != null ? (ref2 = ref1.google) != null ? ref2.maps : void 0 : void 0) != null) { 176 window.google = window.parent.google; 177 return mapsPromise.resolve(); 178 } 179 window.__googleMapsApiOnLoadCallback = function() { 180 mapsPromise.resolve(window.google.maps); 181 return delete window.__googleMapsApiOnLoadCallback; 182 }; 183 $.get(BASE_URL + "/api_keys/google_maps").then(function(response) { 184 var head, script; 185 script = document.createElement('script');
186 script.src = "https://maps.googleapis.com/maps/api/js?callback=__googleMapsApiOnLoadCallback&key=" + response.key + "&libraries=places&loading=async"; 187 script.async = true; 188 head = document.querySelector('head'); 189 return head.appendChild(script); 190 }); 191 return mapsPromise; 192 }; 193 getMapBoundsfromLocations = (function(_this) { 194 return function(locations) { 195 var bounds, i, len, location; 196 bounds = new google.maps.LatLngBounds; 197 for (i = 0, len = locations.length; i < len; i++) { 198 location = locations[i]; 199 bounds.extend(location.coordinates); 200 } 201 if (locations.length === 1) { 202 bounds.extend({ 203 lat: location.coordinates.lat + MINIMUM_BOUNDS_DELTA, 204 lng: location.coordinates.lng + MINIMUM_BOUNDS_DELTA 205 }); 206 bounds.extend({ 207 lat: location.coordinates.lat - MINIMUM_BOUNDS_DELTA, 208 lng: location.coordinates.lng - MINIMUM_BOUNDS_DELTA 209 }); 210 } 211 return bounds; 212 }; 213 })(this); 214 this.mapEmbeds = { 215 populate: populate 216 }; 217 window.parent._4ORMAT.MARKER_THEMES = window._4ORMAT.MARKER_THEMES; 218 if (!_4ORMAT_DATA.page.content_editable) { 219 $modules = $('[data-editable-type="map"]'); 220 return $modules.each(function(_index, module) { 221 return populate($(module)); 222 }); 223 } 224 }).call(_4ORMAT); 225 226}).call(this);
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.