1(function ($) { 2 3 "use strict" 4 5 var map, marker, markers, custom_html_icon, $window = $(window); 6 7 var emptyLatLng = function(data) { 8 9 if ( typeof( data ) == 'number' || typeof( data ) == 'boolean' ) { 10 return false; 11 } 12 if ( typeof( data ) == 'undefined' || data === null ) { 13 return true; 14 } 15 if ( typeof( data.length ) != 'undefined' ) { 16 return data.length === 0; 17 } 18 var count = 0; 19 for ( var i in data ) { 20 if ( Object.prototype.hasOwnProperty.call(data, i) ) { 21 count++; 22 } 23 } 24 return count === 0; 25 }, addPinToMap = function(obj) { 26 var $item = $(obj); 27 28 if ( emptyLatLng($item.data('latitude')) || emptyLatLng($item.data('longitude')) ) { 29 return false; 30 } 31 32 var svg = wp.template('empty-icon-svg'), 33 iconSVG = svg(suround_global_vars); 34 35 marker = L.marker([$item.data('latitude'), $item.data('longitude')], { 36 icon: new custom_html_icon({ 37 html: "<div class='map-pin'>" + iconSVG + "</div>" 38 }) 39 }); 40 41 marker.attachment_url = $item.data('attachment-url'); 42 43 marker.bindPopup( $item.html(), { maxWidth: 315 } ) 44 ._popup.section_id = $item.data('post-id'); 45 46 markers.addLayer(marker); 47 48 return true; 49 } 50 51 SuroundMap.Maps = { 52 options: { 53 scrollWheelZoom: false, 54 zoomControl: true, 55 maxZoom: 17, 56 gestureHandling: true, 57 fullscreenControl: true, 58 skin: "skin1", 59 }, 60 skins: [], 61 init: function () { }, 62 }, SuroundMap.Maps.Map = function (e) { 63 this.$el = $(e), this.init(); 64 }, SuroundMap.Maps.Map.prototype.init = function () { 65 66 if ( typeof L !== "object" || !L.hasOwnProperty('map') ) { 67 return; 68 } 69 70 this.options = $.extend({}, SuroundMap.Maps.options, this.$el.data('options')); 71 72 map = L.map(this.$el[0], { 73 scrollWheelZoom: this.options.scrollWheelZoom, 74 gestureHandling: this.options.gestureHandling, 75 zoomControl: this.options.zoomControl, 76 maxZoom: this.options.maxZoom, 77 fullscreenControl: this.options.fullscreenControl 78 }); 79 80 L.mapboxGL({ 81 accessToken: SuroundMap.MapConfig.AccessToken, 82 style: this.options.skin == 'custom' ? SuroundMap.MapConfig.CustomSkin : SuroundMap.Maps.skins[this.options.skin] ? SuroundMap.Maps.skins[this.options.skin] : SuroundMap.Maps.skins.skin1 83 }).addTo(map); 84 85 markers = new L.markerClusterGroup({ 86 spiderfyOnMaxZoom: true, 87 showCoverageOnHover: true 88 }); 89 90 custom_html_icon = L.HtmlIcon.extend({ 91 options: { 92 iconSize: [37, 42], 93 iconAnchor: [25, 58], 94 popupAnchor: [3, -3] 95 } 96 }); 97 98 var $listings = $('.suround-post-hidden-map'), 99 $listing = $('.entry-col', $listings), 100 listingWithLocation = 0; 101 102 if ( !$listing.length ) { 103 return; 104 } 105 106 $listing.each(function (i, obj) { 107 108 var cardHasLocation = addPinToMap(obj); 109 110 // marker.openPopup(); 111 112 if ( cardHasLocation ) { 113 listingWithLocation += 1; 114 } 115 116 }); 117 118 if ( listingWithLocation != 0 ) { 119 120 map.fitBounds(markers.getBounds(), { 121 padding: [50, 50, 50, 50], 122 easing: function (t) { 123 return t * (2 - t); 124 } 125 }); 126 127 map.addLayer(markers); 128 129 if ( this.options.single ) { 130 marker.openPopup(); 131 } 132 133 } 134 135 map._onResize(); 136 137 $window.on('pxg:refreshmap', function () { 138 map._onResize(); 139 }); 140 141 map.on('popupopen', function (el) { 142 if ( el.popup.section_id ) { 143 Suround.modules.scrollSideMapSidebar(el.popup.section_id); 144 } 145 }); 146 147 }, SuroundMap.Maps.skins = { 148 skin1: "mapbox://styles/mapbox/streets-v10", 149 skin2: "mapbox://styles/mapbox/outdoors-v10", 150 skin3: "mapbox://styles/mapbox/light-v9", 151 skin4: "mapbox://styles/mapbox/dark-v9", 152 skin5: "mapbox://styles/mapbox/satellite-streets-v10", 153 skin6: "mapbox://styles/mapbox/navigation-preview-day-v4", 154 skin7: "mapbox://styles/mapbox/navigation-preview-night-v4", 155 skin8: "mapbox://styles/mapbox/navigation-guidance-day-v4", 156 skin9: "mapbox://styles/mapbox/navigation-guidance-night-v4" 157 }, SuroundMap.Maps.init = function () { 158 159 if ( !$('.suround-post-gmap').length ) return; 160 161 $window.on('load', function () { 162 $('.suround-post-gmap').each(function (i, el) { 163 new SuroundMap.Maps.Map(el); 164 }) 165 }); 166 167 }, SuroundMap.Maps.init(); 168 169}
169)(jQuery);
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.