1/** 2 * EventON Generate Google Maps Function 3 * @version 2.4 4 */ 5 6//return; 7 8(function($){ 9 10// map loader function 11 $.fn.evoGenmaps = function(opt){ 12 13 var defaults = { 14 delay: 0, 15 fnt: 5, 16 cal: '', 17 SC: '', 18 map_canvas_id: '', 19 location_type:'', 20 address:'', 21 zoomlevel:'', 22 mapformat:'', 23 scroll:false, 24 iconURL:'', 25 trigger_point: '', 26 }; 27 var options = $.extend({}, defaults, opt); 28 29 //console.log(options); 30 31 var geocoder; 32 33 var code = {}; 34 obj = this; 35 code.obj = this; 36 37 mapBox = $('#'+options.map_canvas_id); 38 39 code = { 40 init:function(){ 41 // Skip if map box isnât visible or already drawn 42 if (!mapBox.is(':visible') || mapBox.find('.gm-style').length > 0) return; 43 44 mapBox.html( evo_general_params.html.preload_gmap); 45 46 //if( mapBox.hasClass('mDrawn') ) return; 47 48 // Set calendar if present 49 options.cal = obj.closest('.ajde_evcal_calendar').length ? obj.closest('.ajde_evcal_calendar') : options.cal; 50 code.process_SC(); 51 52 // various methods to draw map 53 // load map on specified elements directly 54 if(options.fnt==5){ 55 if(options.delay==0){ code.draw_map(); }else{ 56 setTimeout(code.draw_map, options.delay, this); 57 } 58 } 59 60 // deprecating rest 4.6 61 // multiple maps at same time 62 if(options.fnt==1){ 63 code.load_gmap(); 64 } 65 66 if(options.fnt==2){ 67 if(options.delay==0){ code.load_gmap(); }else{ 68 setTimeout(code.load_gmap, options.delay, this); 69 } 70 } 71 if(options.fnt==3){ code.load_gmap(); } 72 73 // gmaps on popup 74 if(options.fnt==4){ 75 // check if gmaps should run 76 if( this.attr('data-gmtrig')=='1' && this.attr('data-gmap_status')!='null'){ 77 code.load_gmap(); 78 } 79 } 80 }, 81 // add unique id for map area 82 process_unique_map_id: function(){ 83 var map_element = obj.closest('.eventon_list_event').find('.evo_metarow_gmap'); 84 if (!map_element.length || !map_element.attr('id')) return false; 85 86 var map_element = obj.closest('.eventon_list_event').find('.evo_metarow_gmap'); 87 88 var randomnumber = Math.floor(Math.random() * (99 - 10 + 1)) + 10; 89 options.map_canvas_id = map_element.attr('id') + '_' + randomnumber; 90 map_element.attr('id', options.map_canvas_id); 91 return options.map_canvas_id; 92 }, 93 process_SC: function(){ 94 if (options.SC || !options.cal) return; 95 options.SC = options.cal.evo_shortcode_data(); 96 }, 97 98 // load google map 99 load_gmap: function(){ 100 var SC = options.SC, 101 ev_location = obj.find('.event_location_attrs'), 102 location_type = ev_location.attr('data-location_type'); 103 104 options.address = location_type == 'address' ? ev_location.attr('data-location_address') : ev_location.attr('data-latlng'); 105 options.location_type = location_type == 'address' ? 'add' : 'latlng'; 106 options.iconURL = SC && SC.mapiconurl ? SC.mapiconurl : options.iconURL; 107 108 if (!options.address) { 109 console.log('Location address missing in options.address'); 110 return false; 111 } 112 113 var map_canvas_id = code.process_unique_map_id(); 114 if (!map_canvas_id || !$('#' + map_canvas_id).length) { 115 console.log('Map element with id missing in page'); 116 return false; 117 } 118 119 options.zoomlevel = SC && SC.mapzoom ? parseInt(SC.mapzoom) : 12; 120 options.scroll = SC.mapscroll; 121 options.mapformat = SC.mapformat; 122 123 code.draw_map(); 124 }, 125 126 // final draw 127 draw_map: function(){ 128 if (!options.map_canvas_id || !$('#' + options.map_canvas_id).length) { 129 console.log('Map element with id missing in page'); 130 return false; 131 } 132 133 // map styles 134 if( typeof gmapstyles !== 'undefined' && gmapstyles != 'default'){ 135 options.styles = JSON.parse(gmapstyles); 136 } 137 138 var myOptions = { 139 mapTypeId: options.mapformat, 140 zoom: options.zoomlevel, 141 scrollwheel: options.scroll != 'false', 142 zoomControl: true, 143 draggable: options.scroll != 'false', 144 mapId: 'DEMO_MAP_ID' 145 // Removed mapId to allow custom styles 146 }; 147 148 149 var map_canvas = document.getElementById(options.map_canvas_id), 150 map = new google.maps.Map(map_canvas, myOptions), 151 geocoder = new google.maps.Geocoder(); 152 153 // address from latlng 154 if(options.location_type=='latlng' && options.address !== undefined){ 155 var latlngStr = options.address.split(",",2); 156 var lat = parseFloat(latlngStr[0]); 157 var lng = parseFloat(latlngStr[1]); 158 var latlng = new google.maps.LatLng(lat, lng); 159 160 geocoder.geocode({'latLng': latlng}, function(results, status) { 161 if (status == google.maps.GeocoderStatus.OK) { 162 163 map.setCenter(latlng); 164 new google.maps.marker.AdvancedMarkerElement({ 165 map: map, 166 position: latlng 167 }); 168 169 } else { 170 map_canvas.style.display = 'none'; 171 } 172 }); 173 174 }else if(options.address ){ 175 geocoder.geocode( { 'address': options.address}, function(results, status) { 176 if (status == google.maps.GeocoderStatus.OK) { 177 map.setCenter(results[0].geometry.location); 178 new google.maps.Marker({ 179 map: map, 180 position: results[0].geometry.location, 181 icon: options.iconURL 182 }); 183 184 } else { map_canvas.style.display = 'none'; } 185 }); 186 } 187 188 // mark as map drawn 189 $('#'+ options.map_canvas_id).addClass('mDrawn'); 190 } 191 } 192 193 194 // INIT 195 code.init(); 196 }; 197 198 199// trigger load google map on dynamic map element u4.6.1 200 $.fn.evo_load_gmap = function(opt){ 201 202 var defs = { map_canvas_id: '', delay: 0, trigger_point: '' }, 203 OO = $.extend({}, defs, opt), 204 EL = this, 205 EL_id = OO.map_canvas_id || EL.attr('id'), 206 location_type = EL.data('location_type') == 'add' ? 'add' : 'latlng', 207 address = location_type == 'add' ? EL.data('address') : EL.data('latlng'), 208 scrollwheel = EL.data('scroll') == 'yes', 209 elms = document.querySelectorAll("[id='" + EL_id + "']"); 210 211 // Ensure unique ID 212 if (elms.length > 1) { 213 var randomnumber = Math.floor(Math.random() * (99 - 10 + 1)) + 10; 214 EL_id = EL_id + '_' + randomnumber; 215 EL.attr('id', EL_id); 216 } 217 218 // Determine delay
219 var __delay = OO.delay || EL.data('delay') || 0; 220 221 // load the map 222 EL.evoGenmaps({ 223 map_canvas_id: EL_id, 224 fnt: 5, 225 location_type: location_type, 226 address: address, 227 zoomlevel: parseInt(EL.data('zoom')), 228 mapformat: EL.data('mty'), 229 scroll: scrollwheel, 230 iconURL: EL.data('mapicon') || '', 231 delay: __delay, 232 trigger_point: OO.trigger_point 233 }); 234 235 }; 236 237 238 239}(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.