1riot.tag2('riot-solr-result-map', '<div class="map-results"></div> <div if="{opts.result_summary.enable}" class="result-summary"> <table> <thead> <tr> <th each="{th in summaryHeaders}"> {th.trim()} </th> </tr> </thead> <tbody> <tr onclick="{linkToItem}" onmouseover="{fireEvent}" onmouseleave="{fireEvent}" each="{marker in opts.markers}" class="{marker}"> <td each="{col in parent.summaryCols}"> {marker.item[col]} </td> </tr> </tbody> </table> </div>', '@-webkit-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } @-moz-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } @-o-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } @keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } riot-solr-result-map,[riot-tag="riot-solr-result-map"],[data-is="riot-solr-result-map"]{ display: block; } riot-solr-result-map,[riot-tag="riot-solr-result-map"],[data-is="riot-solr-result-map"]{ width: 100%; height: auto; background: rgba(17, 17, 17, 0.1); transition: all .00001s ease-out; } riot-solr-result-map .gm-style .gm-style-iw,[riot-tag="riot-solr-result-map"] .gm-style .gm-style-iw,[data-is="riot-solr-result-map"] .gm-style .gm-style-iw{ min-height: 240px; } riot-solr-result-map rc-riot-result-list-item,[riot-tag="riot-solr-result-map"] rc-riot-result-list-item,[data-is="riot-solr-result-map"] rc-riot-result-list-item,riot-solr-result-map [riot-tag="rc-riot-result-list-item"],[riot-tag="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"],[data-is="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"],riot-solr-result-map [data-is="rc-riot-result-list-item"],[riot-tag="riot-solr-result-map"] [data-is="rc-riot-result-list-item"],[data-is="riot-solr-result-map"] [data-is="rc-riot-result-list-item"]{ min-width: 220px; } riot-solr-result-map rc-riot-result-list-item > .tag-content,[riot-tag="riot-solr-result-map"] rc-riot-result-list-item > .tag-content,[data-is="riot-solr-result-map"] rc-riot-result-list-item > .tag-content,riot-solr-result-map [riot-tag="rc-riot-result-list-item"] > .tag-content,[riot-tag="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content,[data-is="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content,riot-solr-result-map [data-is="rc-riot-result-list-item"] > .tag-content,[riot-tag="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content,[data-is="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content{ box-shadow: none; } riot-solr-result-map rc-riot-result-list-item > .tag-content:hover,[riot-tag="riot-solr-result-map"] rc-riot-result-list-item > .tag-content:hover,[data-is="riot-solr-result-map"] rc-riot-result-list-item > .tag-content:hover,riot-solr-result-map rc-riot-result-list-item > .tag-content:active,[riot-tag="riot-solr-result-map"] rc-riot-result-list-item > .tag-content:active,[data-is="riot-solr-result-map"] rc-riot-result-list-item > .tag-content:active,riot-solr-result-map [riot-tag="rc-riot-result-list-item"] > .tag-content:hover,[riot-tag="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content:hover,[data-is="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content:hover,riot-solr-result-map [riot-tag="rc-riot-result-list-item"] > .tag-content:active,[riot-tag="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content:active,[data-is="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content:active,riot-solr-result-map [data-is="rc-riot-result-list-item"] > .tag-content:hover,[riot-tag="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content:hover,[data-is="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content:hover,riot-solr-result-map [data-is="rc-riot-result-list-item"] > .tag-content:active,[riot-tag="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content:active,[data-is="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content:active{ background-color: #fff; } riot-solr-result-map .riot-solr-result-map-control,[riot-tag="riot-solr-result-map"] .riot-solr-result-map-control,[data-is="riot-solr-result-map"] .riot-solr-result-map-control{ background: #fff; border: 2px solid #fff; border-radius: 3px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); color: #191919; font-size: 13px; padding-left: 5px; padding-right: 5px; } riot-solr-result-map .results-count,[riot-tag="riot-solr-result-map"] .results-count,[data-is="riot-solr-result-map"] .results-count{ margin: 10px; } riot-solr-result-map .toggle-query-enabled,[riot-tag="riot-solr-result-map"] .toggle-query-enabled,[data-is="riot-solr-result-map"] .toggle-query-enabled{ border-radius: 0; border-bottom-left-radius: 3px; } riot-solr-result-map .result-summary tr,[riot-tag="riot-solr-result-map"] .result-summary tr,[data-is="riot-solr-result-map"] .result-summary tr{ cursor: pointer; } riot-solr-result-map .riot-solr-map-marker,[riot-tag="riot-solr-result-map"] .riot-solr-map-marker,[data-is="riot-solr-result-map"] .riot-solr-map-marker{ border: 1px solid #3C3C3C; background-color: #ACACAC; position: absolute; cursor: pointer; width: 10px; height: 10px; border-radius: 5px; z-index: 500; }
1 riot-solr-result-map .riot-solr-map-marker.focused,[riot-tag="riot-solr-result-map"] .riot-solr-map-marker.focused,[data-is="riot-solr-result-map"] .riot-solr-map-marker.focused{ transform: scale(2, 2); background-color: lightblue; z-index: 1000; } @-webkit-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } @-moz-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } @-o-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } @keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } } riot-solr-result-map,[riot-tag="riot-solr-result-map"],[data-is="riot-solr-result-map"]{ display: block; } riot-solr-result-map,[riot-tag="riot-solr-result-map"],[data-is="riot-solr-result-map"]{ width: 100%; height: auto; background: rgba(17, 17, 17, 0.1); transition: all .00001s ease-out; } riot-solr-result-map .gm-style .gm-style-iw,[riot-tag="riot-solr-result-map"] .gm-style .gm-style-iw,[data-is="riot-solr-result-map"] .gm-style .gm-style-iw{ min-height: 240px; } riot-solr-result-map rc-riot-result-list-item,[riot-tag="riot-solr-result-map"] rc-riot-result-list-item,[data-is="riot-solr-result-map"] rc-riot-result-list-item,riot-solr-result-map [riot-tag="rc-riot-result-list-item"],[riot-tag="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"],[data-is="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"],riot-solr-result-map [data-is="rc-riot-result-list-item"],[riot-tag="riot-solr-result-map"] [data-is="rc-riot-result-list-item"],[data-is="riot-solr-result-map"] [data-is="rc-riot-result-list-item"]{ min-width: 220px; } riot-solr-result-map rc-riot-result-list-item > .tag-content,[riot-tag="riot-solr-result-map"] rc-riot-result-list-item > .tag-content,[data-is="riot-solr-result-map"] rc-riot-result-list-item > .tag-content,riot-solr-result-map [riot-tag="rc-riot-result-list-item"] > .tag-content,[riot-tag="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content,[data-is="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content,riot-solr-result-map [data-is="rc-riot-result-list-item"] > .tag-content,[riot-tag="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content,[data-is="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content{ box-shadow: none; } riot-solr-result-map rc-riot-result-list-item > .tag-content:hover,[riot-tag="riot-solr-result-map"] rc-riot-result-list-item > .tag-content:hover,[data-is="riot-solr-result-map"] rc-riot-result-list-item > .tag-content:hover,riot-solr-result-map rc-riot-result-list-item > .tag-content:active,[riot-tag="riot-solr-result-map"] rc-riot-result-list-item > .tag-content:active,[data-is="riot-solr-result-map"] rc-riot-result-list-item > .tag-content:active,riot-solr-result-map [riot-tag="rc-riot-result-list-item"] > .tag-content:hover,[riot-tag="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content:hover,[data-is="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content:hover,riot-solr-result-map [riot-tag="rc-riot-result-list-item"] > .tag-content:active,[riot-tag="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content:active,[data-is="riot-solr-result-map"] [riot-tag="rc-riot-result-list-item"] > .tag-content:active,riot-solr-result-map [data-is="rc-riot-result-list-item"] > .tag-content:hover,[riot-tag="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content:hover,[data-is="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content:hover,riot-solr-result-map [data-is="rc-riot-result-list-item"] > .tag-content:active,[riot-tag="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content:active,[data-is="riot-solr-result-map"] [data-is="rc-riot-result-list-item"] > .tag-content:active{ background-color: #fff; } riot-solr-result-map .riot-solr-result-map-control,[riot-tag="riot-solr-result-map"] .riot-solr-result-map-control,[data-is="riot-solr-result-map"] .riot-solr-result-map-control{ background: #fff; border: 2px solid #fff; border-radius: 3px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); color: #191919; font-size: 13px; padding-left: 5px; padding-right: 5px; } riot-solr-result-map .results-count,[riot-tag="riot-solr-result-map"] .results-count,[data-is="riot-solr-result-map"] .results-count{ margin: 10px; } riot-solr-result-map .toggle-query-enabled,[riot-tag="riot-solr-result-map"] .toggle-query-enabled,[data-is="riot-solr-result-map"] .toggle-query-enabled{ border-radius: 0; border-bottom-left-radius: 3px; } riot-solr-result-map .result-summary tr,[riot-tag="riot-solr-result-map"] .result-summary tr,[data-is="riot-solr-result-map"] .result-summary tr{ cursor: pointer; } riot-solr-result-map .riot-solr-map-marker,[riot-tag="riot-solr-result-map"] .riot-solr-map-marker,[data-is="riot-solr-result-map"] .riot-solr-map-marker{ border: 1px solid #3C3C3C; background-color: #ACACAC; position: absolute; cursor: pointer; width: 10px; height: 10px; border-radius: 5px; z-index: 500; }
1 riot-solr-result-map .riot-solr-map-marker.focused,[riot-tag="riot-solr-result-map"] .riot-solr-map-marker.focused,[data-is="riot-solr-result-map"] .riot-solr-map-marker.focused{ transform: scale(2, 2); background-color: lightblue; z-index: 1000; }', '', function(opts) { 2 this.mixin('RiotTagsChildren'); 3 this.mixin('RiotSolrConnection'); 4 this.mixin('RiotSolrItemsContainer'); 5 this.mixin('RiotSolrLinkedItem'); 6 this.mixin('RiotSolrIntersectionObserver'); 7 (function($, tag) { 8 var didResize = false; 9 tag.RiotSolrManager.observable.on('RiotSolrNoResultsBehavior', function() { 10 tag.clearMarkers() 11 }); 12 13 tag.observeAfterFirstVisible = false 14 15 if(opts.result_summary && opts.result_summary.enable) { 16 tag.summaryHeaders = opts.result_summary.headers.split(','); 17 tag.summaryCols = opts.result_summary.columns.split(','); 18 } 19 20 if (opts.enable_query) { 21 tag.instance = { 22 lat: new AjaxSolr.RiotSolrFacetRanges({ 23 id: 'RiotSolrFacetRanges-' + opts.lat, 24 field: opts.lat, 25 observable: tag, 26 formatCurrentSearchLabel: false 27 }), 28 lng: new AjaxSolr.RiotSolrFacetRanges({ 29 id: 'RiotSolrFacetRanges-' + opts.lon, 30 field: opts.lon, 31 observable: tag, 32 formatCurrentSearchLabel: false 33 }) 34 }; 35 tag.RiotSolrManager.observable.on('RiotSolrAddWidgets', function(manager) { 36 manager.addWidget(tag.instance.lat); 37 manager.addWidget(tag.instance.lng); 38 }); 39 } 40 41 tag.item_markers = {}; 42 tag.iw = new google.maps.InfoWindow(); 43 tag.one('update', function() { 44 tag.root.addEventListener('transitionend', function(ev) { 45 if (typeof opts.mapObj != 'undefined' && (ev.propertyName == 'width' || ev.propertyName == 'height')) { 46 didResize = true; 47 } 48 }); 49 }); 50 tag.on('RiotSolrItemsUpdated', function() { 51 tag.items = tag.getRiotSolrItems(); 52 if(!tag.hasBeenVisible && tag.canObserveInt()) { 53 54 tag.one('RiotSolrIntersect', function() { 55 if(tag.hasBeenVisible) { 56 tag.trigger('RiotSolrItemsUpdated') 57 } 58 }) 59 return 60 } 61 if (!opts.mapObj) { 62 if (!opts.gmapParams) { 63 function getCustomMapTheme() { 64 if(!opts.custom_map_theme){ 65 return null 66 } 67 try{ 68 var theme = JSON.parse(opts.custom_map_theme); 69 } 70 catch(e){ 71 var theme = null; 72 } 73 return theme; 74 } 75 function getMapStyles () { 76 var styles = []; 77 if (!opts.map_styles) { 78 return [ 79 google.maps.MapTypeId['ROADMAP'], 80 google.maps.MapTypeId['SATELLITE'], 81 ]; 82 } 83 84 for (style in opts.map_styles) { 85 if (opts.map_styles[style] === style) { 86 styles.push(google.maps.MapTypeId[style]); 87 } 88 } 89 90 if (opts.default_map_style && styles.indexOf(google.maps.MapTypeId[opts.default_map_style]) < 0) { 91 styles.push(google.maps.MapTypeId[opts.default_map_style]); 92 } 93 94 return styles; 95 } 96 opts.gmapParams = { 97 center: { 98 lat: parseFloat(opts.default_query_lat) || 53.806, 99 lng: parseFloat(opts.default_query_lon) || -1.535 100 }, 101 zoom: parseInt(opts.default_query_zoom) || (parseInt(opts.zoom) > 0 ? parseInt(opts.zoom) : 7), 102 maxZoom: parseInt(opts.maxzoom) || null, 103 disableDefaultUI: true, 104 zoomControl: true, 105 scrollwheel: true, 106 mapTypeControlOptions: { 107 mapTypeIds: getMapStyles(), 108 }, 109 styles: getCustomMapTheme(), 110 mapTypeId: google.maps.MapTypeId[opts.default_map_style] || google.maps.MapTypeId['ROADMAP'], 111 }; 112 opts.markers = []; 113 } 114 115 if (!opts.omsParams) { 116 opts.omsParams = { 117 keepSpiderfied: true 118 }; 119 } 120 $.Deferred(function() { 121 opts.mapObj = new google.maps.Map(tag.root.querySelector('.map-results'), opts.gmapParams); 122 123 if (opts.geojson_url) { 124 opts.mapObj.data.loadGeoJson(opts.geojson_url, { clickable: false }, function() { 125 tag.trigger('GeoJSONLoaded'); 126 opts.geoJSONLoaded = true; 127 tag.processMarkers(); 128 }); 129 } 130 131 $(window).on('resize', function() { 132 didResize = true; 133 }); 134 setInterval(function() { 135 if (didResize) { 136 didResize = false;
137 tag.fitBounds(); 138 } 139 }, 150); 140 this.resolve(); 141 }).done(function() { 142 if (opts.enable_oms) { 143 opts.oms = new OverlappingMarkerSpiderfier(opts.mapObj, opts.omsParams); 144 } 145 tag.processMarkers(); 146 if (opts.enable_query) { 147 opts.mapObj.addListener('dragend', tag.updateQueryBounds); 148 opts.mapObj.addListener('zoom_changed', tag.updateQueryBounds); 149 initializeQueryControls(opts.mapObj); 150 } 151 if ( 152 opts.enable_query && 153 parseInt(opts.default_query_zoom) && 154 parseFloat(opts.default_query_lat) && 155 parseFloat(opts.default_query_lon) && 156 !tag.instance.lat.getCurrentFilterRange() && 157 !tag.instance.lng.getCurrentFilterRange() 158 ) { 159 var updater = setInterval(function() { 160 try { 161 tag.updateQueryBounds.call(opts.mapObj); 162 clearInterval(updater); 163 } catch ($e) {} 164 }, 150); 165 } else { 166 tag.fitBounds(); 167 } 168 }); 169 } else { 170 $.Deferred(function() { 171 tag.clearMarkers(); 172 tag.processMarkers(); 173 if (!opts.enable_query) { 174 tag.fitBounds(); 175 } 176 }); 177 } 178 }); 179 180 tag.updateQueryBounds = function(e) { 181 var bounds = this.getBounds(); 182 if (!bounds) { 183 throw new Error('No bounds set'); 184 } 185 if (!opts.enable_query || opts.query_locked) { 186 return; 187 } 188 var range = {
189 lat: '[' + bounds.getSouthWest().lat() + ' TO ' + bounds.getNorthEast().lat() + ']', 190 lng: '[' + bounds.getSouthWest().lng() + ' TO ' + bounds.getNorthEast().lng() + ']' 191 }; 192 193 if (tag.instance.lat.set(range.lat) && tag.instance.lng.set(range.lng)) { 194 tag.instance.lng.doRequest(); 195 } 196 }; 197 198 tag.fitBounds = function() { 199 var bounds; 200 if (opts.geojson_url && !opts.geoJSONLoaded) { 201 return; 202 } 203 opts.query_locked = true; 204 if (opts.markers && opts.mapObj) { 205 bounds = new google.maps.LatLngBounds(); 206 if (!opts.fix_map_center) { 207 for (var m in opts.markers) { 208 if (opts.markers.hasOwnProperty(m)) { 209 bounds.extend(opts.markers[m].getPosition()); 210 } 211 } 212 } 213 google.maps.event.trigger(opts.mapObj, 'resize'); 214 if (parseInt(opts.zoom) > 0) { 215 if(opts.mapObj.getZoom() > parseInt(opts.zoom)) { 216 opts.mapObj.setZoom(parseInt(opts.zoom)); 217 } 218 if (opts.fix_map_center && opts.fixed_center_lat && opts.fixed_center_lon) { 219 opts.mapObj.setCenter(new google.maps.LatLng( 220 parseFloat(opts.fixed_center_lat) || 53.806, 221 parseFloat(opts.fixed_center_lon) || -1.535 222 )); 223 } else { 224 opts.mapObj.setCenter(bounds.getCenter()); 225 } 226 } 227 else { 228 opts.mapObj.fitBounds(bounds); 229 } 230 google.maps.event.addListenerOnce(opts.mapObj, 'idle', function() { 231 opts.query_locked = false; 232 }); 233 } 234 }; 235 236 tag.getFeaturePolygons = function() { 237 var polygons = []; 238 opts.mapObj.data.forEach(function(feature) { 239 var geometry = feature.getGeometry(); 240 if (geometry.getType() !== 'Polygon') return; 241 242 polygons.push( 243 new google.maps.Polygon({ 244 paths: geometry.getAt(0).getArray(), 245 clickable: false 246 }) 247 ); 248 }); 249 250 return polygons; 251 }; 252 253 tag.processMarkers = function() { 254 if (opts.geojson_url && !opts.geoJSONLoaded) { 255 return; 256 } 257 if (tag.items && opts.mapObj) { 258 var markerObj; 259 tag.featurePolygons = tag.getFeaturePolygons(); 260 opts.markers = []; 261 for (var m in tag.items) { 262 if (isNaN(Number(tag.items[m][opts.lat])) || isNaN(Number(tag.items[m][opts.lon]))) { 263 continue; 264 } 265 if (typeof tag.item_markers[tag.items[m].id] != 'undefined') { 266 markerObj = tag.item_markers[tag.items[m].id]; 267 markerObj.setMap(opts.mapObj); 268 } else { 269 var title; 270 title = tag.items[m][opts.title]; 271 if (!tag.items[m][opts.lat] || !tag.items[m][opts.lon]) { 272 continue; 273 } 274 275 if (opts.bounds_lat || opts.bounds_lon) { 276 var outOfBounds = false; 277 278 if (opts.bounds_lat) { 279 if (parseFloat(tag.items[m][opts.lat]) < parseFloat(opts.bounds_lat)) { 280 outOfBounds = true; 281 } 282 } 283 284 if (opts.bounds_lon) { 285 if (parseFloat(tag.items[m][opts.lon]) < parseFloat(opts.bounds_lon)) { 286 outOfBounds = true; 287 } 288 } 289 } 290 291 if (outOfBounds) { 292 continue; 293 } 294 295 markerObj = new riotSolrMapMarker({ 296 position: new google.maps.LatLng(tag.items[m][opts.lat], tag.items[m][opts.lon]), 297 title: title, 298 map: opts.mapObj, 299 opts: tag.opts, 300 item: tag.items[m], 301 tagType: tag.children[0] ? tag.children[0].tag : 'generic', 302 indexId: tag.RiotSolrManager.indexId 303 }); 304 305 markerObj.addListener('click', function(e) { 306 var iwcontent = ''; 307 if (typeof tag.children[0] != 'undefined') { 308 var iwt = $('<' + tag.children[0].html_tag + ' />'), 309 iwtopts = Object.assign({}, tag.children[0].options, { 310 item: this.item, 311 tag: tag.children[0].tag, 312 linkitem: false 313 }); 314 google.maps.event.clearListeners(tag.iw, 'domready'); 315 tag.iw.addListener('domready', function(e) { 316 $('.map-results ' + tag.children[0].tag).once('rsresultmapmount', function() { 317 riot.mount(this, tag.children[0].tag, iwtopts); 318 }); 319 }); 320 iwcontent += '<' + tag.children[0].tag + ' />'; 321 } 322 else { 323 iwcontent = document.createElement('div') 324 if(tag.opts.info_bubble.title) { 325 iwcontent.innerHTML += '<h4>' + this.item[tag.opts.info_bubble.title] + '</h4>'; 326 } 327 if(tag.opts.info_bubble.image) { 328 iwcontent.innerHTML += '<img src="' + this.item[tag.opts.info_bubble.image] + '" />'; 329 } 330 if(tag.opts.info_bubble.summary) { 331 iwcontent.innerHTML += '<p>' + this.item[tag.opts.info_bubble.summary] + '</p>'; 332 } 333 if(tag.opts.info_bubble.link) { 334 var linkTxt = tag.opts.txt.link_text ? tag.opts.txt.link_text : 'More Details'; 335 iwcontent.innerHTML += '<a taget="_blank" href="'+ this.item[tag.opts.info_bubble.link] +'">'+ linkTxt +'</a>' 336 } 337 } 338 tag.iw.setContent(iwcontent); 339 tag.iw.open(opts.mapObj, this); 340 tag.RiotSolrLinkedItem.trigger('LinkedItemFocus', this.item); 341 });
342 tag.item_markers[tag.items[m].id] = markerObj; 343 } 344 opts.markers.push(markerObj); 345 if (opts.enable_oms) { 346 opts.oms.addMarker(markerObj); 347 } 348 349 tag.trigger('MarkerPlaced', markerObj, tag.items[m]); 350 } 351 } 352 tag.update() 353 354 if(tag.opts.enable_clusters){ 355 if(!tag.markerClusterer){ 356 var clusterOptions = { 357 imagePath: '/sites/all/libraries/js_marker_clusterer/images/m', 358 minimumClusterSize:3, 359 maxZoom:15, 360 gridSize:50 361 }; 362 tag.markerClusterer = new MarkerClusterer(opts.mapObj, opts.markers, clusterOptions); 363 } 364 else{ 365 tag.markerClusterer.addMarkers(opts.markers); 366 } 367 } 368 }; 369 370 tag.clearMarkers = function() { 371 if (opts.markers) { 372 tag.iw.close(); 373 for (var m in opts.markers) { 374 if (opts.markers.hasOwnProperty(m)) { 375 opts.markers[m].setMap(null); 376 } 377 } 378 if(tag.markerClusterer){ 379 tag.markerClusterer.clearMarkers(); 380 } 381 if(tag.oms){ 382 tag.oms.removeAllMarkers(); 383 } 384 } 385 }; 386 387 tag.fireEvent = function(e) { 388 var evObj = document.createEvent('Events'); 389 evObj.initEvent(e.type, true, false); 390 e.item.marker.div.dispatchEvent(evObj); 391 }; 392 393 tag.linkToItem = function(e) { 394 var item = e.item.marker.item; 395 if(!tag.opts.result_summary.link || !tag.opts.result_summary.link_field) { 396 return false; 397 } 398 399 window.location.href = item[tag.opts.result_summary.link_field]; 400 }; 401 402 tag.RiotSolrLinkedItem.on('LinkedItemFocus', function(item) { 403 var i, m; 404 if (typeof tag.item_markers != 'undefined' && typeof tag.item_markers[item.id] != 'undefined') { 405 for(i in tag.item_markers) { 406 m = tag.item_markers[i]; 407 408 if(!m.div) { 409 continue; 410 } 411 412 if (item.id === m.item.id) { 413 m.div.classList.add('focused'); 414 } 415 else { 416 m.div.classList.remove('focused'); 417 } 418 } 419 } 420 }); 421 422 var procc = tag.processChildren; 423 tag.processChildren = function() { 424 procc.apply(tag); 425 if (typeof tag.children != 'undefined' && typeof tag.children[0] !== 'undefined') { 426 tag.children[0].mounted = true; 427 } 428 }; 429 430 function initializeQueryControls(map) { 431 var $toggleQueryControl = $( 432 '<div class="riot-solr-result-map-control gm-style toggle-query-enabled"><label><input type="checkbox" /> Map Search</label></div>' 433 ); 434 var $countResultsControl = $('<div class="riot-solr-result-map-control gm-style results-count"></div>'); 435 436 $toggleQueryControl.find('input[type=checkbox]').attr('checked', opts.enable_query).on('change', function() { 437 opts.enable_query = !!this.checked; 438 if (opts.enable_query) { 439 tag.updateQueryBounds.call(opts.mapObj); 440 } 441 }); 442 443 let checkpoint = 1; 444 RiotTagsDispatch.on('RiotSolrItemsUpdated', function(tag, items) { 445 let count = items.length; 446 let maxCount = parseInt(tag.RiotSolrManager.store.params.rows.value) || 500; 447 let message; 448 449 if (!checkpoint) { 450 return; 451 } 452 453 if (count === maxCount) { 454 message = 'Only ' + items.length + ' results shown -- use Map Search for more.'; 455 } else { 456 message = items.length + ' Results'; 457 } 458 459 $countResultsControl.text(message); 460 checkpoint = 0; 461 }); 462 463 map.controls[google.maps.ControlPosition.TOP_RIGHT].push($toggleQueryControl[0]); 464 map.controls[google.maps.ControlPosition.TOP_CENTER].push($countResultsControl[0]); 465 } 466 })(jQuery, this); 467 468 this.mixin('RiotTagsChildren'); 469 this.mixin('RiotSolrConnection'); 470 this.mixin('RiotSolrItemsContainer'); 471 this.mixin('RiotSolrLinkedItem'); 472 this.mixin('RiotSolrIntersectionObserver'); 473 (function($, tag) { 474 var didResize = false; 475 tag.RiotSolrManager.observable.on('RiotSolrNoResultsBehavior', function() { 476 tag.clearMarkers() 477 }); 478 479 tag.observeAfterFirstVisible = false 480 481 if(opts.result_summary && opts.result_summary.enable) { 482 tag.summaryHeaders = opts.result_summary.headers.split(','); 483 tag.summaryCols = opts.result_summary.columns.split(','); 484 } 485
486 if (opts.enable_query) { 487 tag.instance = { 488 lat: new AjaxSolr.RiotSolrFacetRanges({ 489 id: 'RiotSolrFacetRanges-' + opts.lat, 490 field: opts.lat, 491 observable: tag, 492 formatCurrentSearchLabel: false 493 }), 494 lng: new AjaxSolr.RiotSolrFacetRanges({ 495 id: 'RiotSolrFacetRanges-' + opts.lon, 496 field: opts.lon, 497 observable: tag, 498 formatCurrentSearchLabel: false 499 }) 500 }; 501 tag.RiotSolrManager.observable.on('RiotSolrAddWidgets', function(manager) { 502 manager.addWidget(tag.instance.lat); 503 manager.addWidget(tag.instance.lng); 504 }); 505 } 506 507 tag.item_markers = {}; 508 tag.iw = new google.maps.InfoWindow(); 509 tag.one('update', function() { 510 tag.root.addEventListener('transitionend', function(ev) { 511 if (typeof opts.mapObj != 'undefined' && (ev.propertyName == 'width' || ev.propertyName == 'height')) { 512 didResize = true; 513 } 514 }); 515 }); 516 tag.on('RiotSolrItemsUpdated', function() { 517 tag.items = tag.getRiotSolrItems(); 518 if(!tag.hasBeenVisible && tag.canObserveInt()) { 519 520 tag.one('RiotSolrIntersect', function() { 521 if(tag.hasBeenVisible) { 522 tag.trigger('RiotSolrItemsUpdated') 523 } 524 }) 525 return 526 } 527 if (!opts.mapObj) { 528 if (!opts.gmapParams) { 529 function getCustomMapTheme() { 530 if(!opts.custom_map_theme){ 531 return null 532 } 533 try{ 534 var theme = JSON.parse(opts.custom_map_theme); 535 } 536 catch(e){ 537 var theme = null; 538 } 539 return theme; 540 } 541 function getMapStyles () { 542 var styles = []; 543 if (!opts.map_styles) { 544 return [ 545 google.maps.MapTypeId['ROADMAP'], 546 google.maps.MapTypeId['SATELLITE'], 547 ]; 548 } 549 550 for (style in opts.map_styles) { 551 if (opts.map_styles[style] === style) { 552 styles.push(google.maps.MapTypeId[style]); 553 } 554 } 555 556 if (opts.default_map_style && styles.indexOf(google.maps.MapTypeId[opts.default_map_style]) < 0) { 557 styles.push(google.maps.MapTypeId[opts.default_map_style]); 558 } 559 560 return styles; 561 } 562 opts.gmapParams = { 563 center: { 564 lat: parseFloat(opts.default_query_lat) || 53.806, 565 lng: parseFloat(opts.default_query_lon) || -1.535 566 }, 567 zoom: parseInt(opts.default_query_zoom) || (parseInt(opts.zoom) > 0 ? parseInt(opts.zoom) : 7), 568 maxZoom: parseInt(opts.maxzoom) || null, 569 scrollwheel: false, 570 mapTypeControlOptions: { 571 mapTypeIds: getMapStyles(), 572 }, 573 styles: getCustomMapTheme(), 574 mapTypeId: google.maps.MapTypeId[opts.default_map_style] || google.maps.MapTypeId['ROADMAP'], 575 }; 576 if (!!opts.disable_autotilt) { 577 opts.gmapParams.tilt = 0; 578 } 579 opts.markers = []; 580 } 581 582 if (!opts.omsParams) { 583 opts.omsParams = { 584 keepSpiderfied: true 585 }; 586 } 587 $.Deferred(function() { 588 opts.mapObj = new google.maps.Map(tag.root.querySelector('.map-results'), opts.gmapParams); 589 590 if (opts.geojson_url) { 591 opts.mapObj.data.loadGeoJson(opts.geojson_url, { clickable: false }, function() { 592 tag.trigger('GeoJSONLoaded'); 593 opts.geoJSONLoaded = true; 594 tag.processMarkers(); 595 }); 596 } 597 598 $(window).on('resize', function() { 599 didResize = true; 600 }); 601 setInterval(function() { 602 if (didResize) { 603 didResize = false; 604 tag.fitBounds(); 605 } 606 }, 150); 607 this.resolve(); 608 }).done(function() { 609 if (opts.enable_oms) { 610 opts.oms = new OverlappingMarkerSpiderfier(opts.mapObj, opts.omsParams); 611 } 612 tag.processMarkers();
613 if (opts.enable_query) { 614 opts.mapObj.addListener('dragend', tag.updateQueryBounds); 615 opts.mapObj.addListener('zoom_changed', tag.updateQueryBounds); 616 initializeQueryControls(opts.mapObj); 617 } 618 if ( 619 opts.enable_query && 620 parseInt(opts.default_query_zoom) && 621 parseFloat(opts.default_query_lat) && 622 parseFloat(opts.default_query_lon) && 623 !tag.instance.lat.getCurrentFilterRange() && 624 !tag.instance.lng.getCurrentFilterRange() 625 ) { 626 var updater = setInterval(function() { 627 try { 628 tag.updateQueryBounds.call(opts.mapObj); 629 clearInterval(updater); 630 } catch ($e) {} 631 }, 150); 632 } else { 633 tag.fitBounds(); 634 } 635 }); 636 } else { 637 $.Deferred(function() { 638 tag.clearMarkers(); 639 tag.processMarkers(); 640 if (!opts.enable_query) { 641 tag.fitBounds(); 642 } 643 }); 644 } 645 }); 646 647 tag.updateQueryBounds = function(e) { 648 var bounds = this.getBounds(); 649 if (!bounds) { 650 throw new Error('No bounds set'); 651 } 652 if (!opts.enable_query || opts.query_locked) { 653 return; 654 } 655 var range = {
656 lat: '[' + bounds.getSouthWest().lat() + ' TO ' + bounds.getNorthEast().lat() + ']', 657 lng: '[' + bounds.getSouthWest().lng() + ' TO ' + bounds.getNorthEast().lng() + ']' 658 }; 659 660 if (tag.instance.lat.set(range.lat) && tag.instance.lng.set(range.lng)) { 661 tag.instance.lng.doRequest(); 662 } 663 }; 664 665 tag.fitBounds = function() { 666 var bounds; 667 if (opts.geojson_url && !opts.geoJSONLoaded) { 668 return; 669 } 670 opts.query_locked = true; 671 if (opts.markers && opts.mapObj) { 672 bounds = new google.maps.LatLngBounds(); 673 if (!opts.fix_map_center) { 674 for (var m in opts.markers) { 675 if (opts.markers.hasOwnProperty(m)) { 676 bounds.extend(opts.markers[m].getPosition()); 677 } 678 } 679 } 680 google.maps.event.trigger(opts.mapObj, 'resize'); 681 if (parseInt(opts.zoom) > 0) { 682 if(opts.mapObj.getZoom() > parseInt(opts.zoom)) { 683 opts.mapObj.setZoom(parseInt(opts.zoom)); 684 } 685 if (opts.fix_map_center && opts.fixed_center_lat && opts.fixed_center_lon) { 686 opts.mapObj.setCenter(new google.maps.LatLng( 687 parseFloat(opts.fixed_center_lat) || 53.806, 688 parseFloat(opts.fixed_center_lon) || -1.535 689 )); 690 } else { 691 opts.mapObj.setCenter(bounds.getCenter()); 692 } 693 } 694 else { 695 opts.mapObj.fitBounds(bounds); 696 } 697 google.maps.event.addListenerOnce(opts.mapObj, 'idle', function() { 698 opts.query_locked = false; 699 }); 700 } 701 }; 702 703 tag.getFeaturePolygons = function() { 704 var polygons = []; 705 opts.mapObj.data.forEach(function(feature) { 706 var geometry = feature.getGeometry(); 707 if (geometry.getType() !== 'Polygon') return; 708 709 polygons.push( 710 new google.maps.Polygon({ 711 paths: geometry.getAt(0).getArray(), 712 clickable: false 713 }) 714 ); 715 }); 716 717 return polygons; 718 }; 719 720 tag.processMarkers = function() { 721 if (opts.geojson_url && !opts.geoJSONLoaded) { 722 return; 723 } 724 if (tag.items && opts.mapObj) { 725 var markerObj; 726 tag.featurePolygons = tag.getFeaturePolygons(); 727 opts.markers = []; 728 for (var m in tag.items) { 729 if (isNaN(Number(tag.items[m][opts.lat])) || isNaN(Number(tag.items[m][opts.lon]))) { 730 continue; 731 } 732 if (typeof tag.item_markers[tag.items[m].id] != 'undefined') { 733 markerObj = tag.item_markers[tag.items[m].id]; 734 markerObj.setMap(opts.mapObj); 735 } else { 736 var title; 737 title = tag.items[m][opts.title]; 738 if (!tag.items[m][opts.lat] || !tag.items[m][opts.lon]) { 739 continue; 740 } 741 742 if (opts.bounds_lat || opts.bounds_lon) { 743 var outOfBounds = false; 744 745 if (opts.bounds_lat) { 746 if (parseFloat(tag.items[m][opts.lat]) < parseFloat(opts.bounds_lat)) { 747 outOfBounds = true; 748 } 749 } 750 751 if (opts.bounds_lon) { 752 if (parseFloat(tag.items[m][opts.lon]) < parseFloat(opts.bounds_lon)) { 753 outOfBounds = true; 754 } 755 } 756 } 757 758 if (outOfBounds) { 759 continue; 760 } 761 762 markerObj = new riotSolrMapMarker({ 763 position: new google.maps.LatLng(tag.items[m][opts.lat], tag.items[m][opts.lon]), 764 title: title, 765 map: opts.mapObj, 766 opts: tag.opts, 767 item: tag.items[m], 768 tagType: tag.children[0] ? tag.children[0].tag : 'generic', 769 indexId: tag.RiotSolrManager.indexId 770 }); 771 772 markerObj.addListener('click', function(e) { 773 var iwcontent = ''; 774 if (typeof tag.children[0] != 'undefined') { 775 var iwt = $('<' + tag.children[0].html_tag + ' />'), 776 iwtopts = Object.assign({}, tag.children[0].options, { 777 item: this.item, 778 tag: tag.children[0].tag, 779 linkitem: false 780 }); 781 google.maps.event.clearListeners(tag.iw, 'domready'); 782 tag.iw.addListener('domready', function(e) { 783 $('.map-results ' + tag.children[0].tag).once('rsresultmapmount', function() { 784 riot.mount(this, tag.children[0].tag, iwtopts); 785 }); 786 }); 787 iwcontent += '<' + tag.children[0].tag + ' />'; 788 } 789 else { 790 iwcontent = document.createElement('div') 791 if(tag.opts.info_bubble.title) { 792 iwcontent.innerHTML += '<h4>' + this.item[tag.opts.info_bubble.title] + '</h4>'; 793 } 794 if(tag.opts.info_bubble.image) { 795 iwcontent.innerHTML += '<img src="' + this.item[tag.opts.info_bubble.image] + '" />'; 796 } 797 if(tag.opts.info_bubble.summary) { 798 iwcontent.innerHTML += '<p>' + this.item[tag.opts.info_bubble.summary] + '</p>'; 799 } 800 if(tag.opts.info_bubble.link) { 801 var linkTxt = tag.opts.txt.link_text ? tag.opts.txt.link_text : 'More Details'; 802 iwcontent.innerHTML += '<a taget="_blank" href="'+ this.item[tag.opts.info_bubble.link] +'">'+ linkTxt +'</a>' 803 } 804 } 805 tag.iw.setContent(iwcontent); 806 tag.iw.open(opts.mapObj, this); 807 tag.RiotSolrLinkedItem.trigger('LinkedItemFocus', this.item); 808 });
809 tag.item_markers[tag.items[m].id] = markerObj; 810 } 811 opts.markers.push(markerObj); 812 if (opts.enable_oms) { 813 opts.oms.addMarker(markerObj); 814 } 815 816 tag.trigger('MarkerPlaced', markerObj, tag.items[m]); 817 } 818 } 819 tag.update() 820 821 if(tag.opts.enable_clusters){ 822 if(!tag.markerClusterer){ 823 var clusterOptions = { 824 imagePath: '/sites/all/libraries/js_marker_clusterer/images/m', 825 minimumClusterSize:3, 826 maxZoom:15, 827 gridSize:50 828 }; 829 tag.markerClusterer = new MarkerClusterer(opts.mapObj, opts.markers, clusterOptions); 830 } 831 else{ 832 tag.markerClusterer.addMarkers(opts.markers); 833 } 834 } 835 }; 836 837 tag.clearMarkers = function() { 838 if (opts.markers) { 839 tag.iw.close(); 840 for (var m in opts.markers) { 841 if (opts.markers.hasOwnProperty(m)) { 842 opts.markers[m].setMap(null); 843 } 844 } 845 if(tag.markerClusterer){ 846 tag.markerClusterer.clearMarkers(); 847 } 848 if(tag.oms){ 849 tag.oms.removeAllMarkers(); 850 } 851 } 852 }; 853 854 tag.fireEvent = function(e) { 855 var evObj = document.createEvent('Events'); 856 evObj.initEvent(e.type, true, false); 857 e.item.marker.div.dispatchEvent(evObj); 858 }; 859 860 tag.linkToItem = function(e) { 861 var item = e.item.marker.item; 862 if(!tag.opts.result_summary.link || !tag.opts.result_summary.link_field) { 863 return false; 864 } 865 866 window.location.href = item[tag.opts.result_summary.link_field]; 867 }; 868 869 tag.RiotSolrLinkedItem.on('LinkedItemFocus', function(item) { 870 var i, m; 871 if (typeof tag.item_markers != 'undefined' && typeof tag.item_markers[item.id] != 'undefined') { 872 for(i in tag.item_markers) { 873 m = tag.item_markers[i]; 874 875 if(!m.div) { 876 continue; 877 } 878 879 if (item.id === m.item.id) { 880 m.div.classList.add('focused'); 881 } 882 else { 883 m.div.classList.remove('focused'); 884 } 885 } 886 } 887 }); 888 889 var procc = tag.processChildren; 890 tag.processChildren = function() { 891 procc.apply(tag); 892 if (typeof tag.children != 'undefined' && typeof tag.children[0] !== 'undefined') { 893 tag.children[0].mounted = true; 894 } 895 }; 896 897 function initializeQueryControls(map) { 898 var $toggleQueryControl = $( 899 '<div class="riot-solr-result-map-control gm-style toggle-query-enabled"><label><input type="checkbox" /> Map Search</label></div>' 900 ); 901 var $countResultsControl = $('<div class="riot-solr-result-map-control gm-style results-count"></div>'); 902 903 $toggleQueryControl.find('input[type=checkbox]').attr('checked', opts.enable_query).on('change', function() { 904 opts.enable_query = !!this.checked; 905 if (opts.enable_query) { 906 tag.updateQueryBounds.call(opts.mapObj); 907 } 908 }); 909 910 let checkpoint = 1; 911 RiotTagsDispatch.on('RiotSolrItemsUpdated', function(tag, items) { 912 let count = items.length; 913 let maxCount = parseInt(tag.RiotSolrManager.store.params.rows.value) || 500; 914 let message; 915 916 if (!checkpoint) { 917 return; 918 } 919 920 if (count === maxCount) { 921 message = 'Only ' + items.length + ' results shown -- use Map Search for more.'; 922 } else { 923 message = items.length + ' Results'; 924 } 925 926 $countResultsControl.text(message); 927 checkpoint = 0; 928 }); 929 930 map.controls[google.maps.ControlPosition.TOP_RIGHT].push($toggleQueryControl[0]); 931 map.controls[google.maps.ControlPosition.TOP_CENTER].push($countResultsControl[0]); 932 } 933 })(jQuery, this); 934});
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.