1/** 2 * EventON Generate Google Maps Function 3 * @version 4.6.1 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 styles:'', 22 zoomlevel:'', 23 mapformat:'', 24 scroll:false, 25 iconURL:'', 26 trigger_point: '', 27 }; 28 var options = $.extend({}, defaults, opt); 29 30 //console.log(options); 31 32 var geocoder; 33 34 var code = {}; 35 obj = this; 36 code.obj = this; 37 38 mapBox = $('#'+options.map_canvas_id); 39 40 code = { 41 init:function(){ 42 43 //return; 44 45 //console.log( $('#'+options.map_canvas_id).hasClass('mDrawn') ? 'y':'d'); 46 //console.log( mapBox.is(':visible') ? 'y':'d'); 47 48 // draw map or not 49 if( !(mapBox.is(':visible')) ) return; // if map box is not visible 50 if( mapBox.find('.gm-style').length > 0 ) return; 51 52 mapBox.html( evo_general_params.html.preload_gmap); 53 54 //if( mapBox.hasClass('mDrawn') ) return; 55 56 // set calendar for event 57 if( obj.closest('.ajde_evcal_calendar').length>0){ 58 options.cal = obj.closest('.ajde_evcal_calendar'); 59 } 60 61 code.process_SC(); 62 63 // various methods to draw map 64 // load map on specified elements directly 65 if(options.fnt==5){ 66 if(options.delay==0){ code.draw_map(); }else{ 67 setTimeout(code.draw_map, options.delay, this); 68 } 69 } 70 71 // deprecating rest 4.6 72 // multiple maps at same time 73 if(options.fnt==1){ 74 code.load_gmap(); 75 } 76 77 if(options.fnt==2){ 78 if(options.delay==0){ code.load_gmap(); }else{ 79 setTimeout(code.load_gmap, options.delay, this); 80 } 81 } 82 if(options.fnt==3){ code.load_gmap(); } 83 84 // gmaps on popup 85 if(options.fnt==4){ 86 // check if gmaps should run 87 if( this.attr('data-gmtrig')=='1' && this.attr('data-gmap_status')!='null'){ 88 code.load_gmap(); 89 } 90 } 91 }, 92 // add unique id for map area 93 process_unique_map_id: function(){ 94 var map_element = obj.closest('.eventon_list_event').find('.evo_metarow_gmap'); 95 96 if(map_element === undefined ) return false; 97 98 var old_map_canvas_id = map_element.attr('id'); 99 if(old_map_canvas_id === undefined) return false; 100 101 // GEN 102 maximum = 99; 103 minimum = 10; 104 var randomnumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; 105 106 map_canvas_id = old_map_canvas_id+'_'+randomnumber; 107 map_element.attr('id', map_canvas_id).addClass('test'); 108 109 options.map_canvas_id = map_canvas_id; 110 111 return map_canvas_id; 112 }, 113 process_SC: function(){ 114 CAL = options.cal; 115 if( options.SC !== '') return; 116 if(CAL == '') return false; 117 options.SC = CAL.evo_shortcode_data(); 118 }, 119 120 // load google map 121 load_gmap: function(){ 122 SC = options.SC; 123 124 var ev_location = obj.find('.event_location_attrs'); 125 126 var location_type = ev_location.attr('data-location_type'); 127 if(location_type=='address'){ 128 options.address = ev_location.attr('data-location_address'); 129 options.location_type = 'add'; 130 }else{ 131 options.address = ev_location.attr('data-latlng'); 132 options.location_type = 'latlng'; 133 } 134 135 // marker icons 136 if( SC !== undefined && SC != '' && 'mapiconurl' in SC) options.iconURL = SC.mapiconurl; 137 138 // make sure there is address present to draw map 139 if( options.address === undefined || options.address == ''){ 140 console.log( 'Location address missing in options.address'); return false; 141 } 142 143 map_canvas_id = code.process_unique_map_id(); 144 145 if(!map_canvas_id || $('#'+map_canvas_id).length == 0){ 146 console.log( 'Map element with id missing in page'); return false; 147 } 148 149 var zoom = SC.mapzoom; 150 options.zoomlevel = (typeof zoom !== 'undefined' && zoom !== false)? parseInt(zoom):12; 151 options.scroll = SC.mapscroll; 152 options.mapformat = SC.mapformat; 153 154 code.draw_map(); 155 }, 156 157 // final draw 158 draw_map: function(){ 159 160 if(!options.map_canvas_id || $('body').find('#'+options.map_canvas_id).length == 0){ 161 console.log( 'Map element with id missing in page'); return false; 162 } 163 164 // map styles 165 if( typeof gmapstyles !== 'undefined' && gmapstyles != 'default'){ 166 options.styles = JSON.parse(gmapstyles); 167 } 168 169 geocoder = new google.maps.Geocoder(); 170 //var latlng = new google.maps.LatLng(45.524732, -122.677031); 171 172 var latlng = 0; 173 174 if(options.scroll == 'false' || options.scroll == false){ 175 176 var myOptions = { 177 //center: latlng, 178 mapTypeId: options.mapformat, 179 zoom: options.zoomlevel, 180 scrollwheel: false, 181 styles: options.styles, 182 zoomControl:true, 183 draggable:false 184 } 185 }else{ 186 var myOptions = { 187 //center: latlng, 188 mapTypeId: options.mapformat, 189 zoom: options.zoomlevel, 190 styles: options.styles, 191 zoomControl:true, 192 scrollwheel: true, 193 } 194 } 195 196 //console.log(myOptions); 197 //console.log(options); 198 199 var map_canvas = document.getElementById(options.map_canvas_id); 200 map = new google.maps.Map(map_canvas, myOptions); 201 202 // address from latlng 203 if(options.location_type=='latlng' && options.address !== undefined){ 204 var latlngStr = options.address.split(",",2); 205 var lat = parseFloat(latlngStr[0]); 206 var lng = parseFloat(latlngStr[1]); 207 var latlng = new google.maps.LatLng(lat, lng); 208 209 geocoder.geocode({'latLng': latlng}, function(results, status) { 210 if (status == google.maps.GeocoderStatus.OK) { 211 /* 212 const {AdvancedMarkerElement} = await google.maps.importLibrary("marker"); 213 214 const marker = new AdvancedMarkerElement({ 215 map: map, 216 position: latlng, 217 icon: options.iconURL 218 });
219 */ 220 221 //console.log(options.iconURL); 222 223 224 var marker = new google.maps.Marker({ 225 map: map, 226 position: latlng, 227 icon: options.iconURL 228 }); 229 230 //map.setCenter(results[0].geometry.location); 231 map.setCenter(marker.getPosition()); 232 console.log('f'); 233 234 } else { 235 document.getElementById(options.map_canvas_id).style.display='none'; 236 } 237 }); 238 239 }else if(options.address==''){ 240 //console.log('t'); 241 }else{ 242 geocoder.geocode( { 'address': options.address}, function(results, status) { 243 if (status == google.maps.GeocoderStatus.OK) { 244 console.log('map '+results[0].geometry.location); 245 map.setCenter(results[0].geometry.location); 246 var marker = new google.maps.Marker({ 247 map: map, 248 position: results[0].geometry.location, 249 icon: options.iconURL 250 }); 251 252 } else { 253 document.getElementById(options.map_canvas_id).style.display='none'; 254 } 255 }); 256 } 257 258 // mark as map drawn 259 $('#'+ options.map_canvas_id).addClass('mDrawn'); 260 } 261 } 262 263 264 // INIT 265 code.init(); 266 }; 267 268 269// trigger load google map on dynamic map element u4.6.1 270 $.fn.evo_load_gmap = function(opt){ 271 var defs = { 272 'map_canvas_id':'', 273 'delay':0, 274 trigger_point:'', 275 }; 276 var OO = $.extend({}, defs, opt); 277 278 EL = this; 279 EL_id = EL.attr('id'); 280 281 if( ('map_canvas_id' in OO ) && OO.map_canvas_id != '' ) EL_id = OO.map_canvas_id; 282 283 var location_type = 'add'; 284 var location_type = EL.data('location_type'); 285 286 if(location_type=='add'){ 287 var address = EL.data('address'); 288 }else{ 289 var address = EL.data('latlng'); 290 var location_type = 'latlng'; 291 } 292 scrollwheel = EL.data('scroll') == 'yes'? true: false; 293 294 var elms = document.querySelectorAll("[id='"+EL_id+"']"); 295 296 // check for unique id 297 if( elms.length > 1){ 298 // GEN 299 maximum = 99; 300 minimum = 10; 301 var randomnumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; 302 EL_id = EL_id+'_'+randomnumber; 303 EL.attr('id', EL_id); 304 } 305 306 // get delay 307 __delay = 0; 308 if( EL.data('delay') ) __delay = EL.data('delay'); 309 if( OO.delay != 0 ) __delay = OO.delay; 310 311 //console.log(EL_id); 312 313 // load the map 314 EL.evoGenmaps({ 315 map_canvas_id: EL.attr('id'), 316 fnt: 5, 317 location_type: location_type, 318 address: address, 319 zoomlevel: parseInt( EL.data('zoom') ), 320 mapformat: EL.data('mty'), 321 scroll: scrollwheel, 322 iconURL: ( EL.data('mapicon') !== undefined ? EL.data('mapicon') : '') , 323 delay: __delay, 324 trigger_point: OO.trigger_point, 325 }); 326 327 }; 328 329 330 331}(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.