PageSourceSearch

https://pridecorpuschristi.com/wp-content/plugins/eventON/assets/js/maps/eventon_gen_maps.js?ver=4.8.2

js pridecorpuschristi.com collected 2026-09-24 20:57:18 UTC 9,740 bytes, 351 lines download raw bytes

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						mapId: 'DEMO_MAP_ID' 
185					}
186				}else{
187					var myOptions = {	
188						//center: latlng,	
189						mapTypeId: options.mapformat,	
190						zoom: options.zoomlevel,
191						styles: options.styles,
192						zoomControl:true,
193						scrollwheel: true,
194						mapId: 'DEMO_MAP_ID' 
195					}
196				}
197
198				//console.log(myOptions);
199				//console.log(options);
200				
201				var map_canvas = document.getElementById(options.map_canvas_id);
202				map = new google.maps.Map(map_canvas, myOptions);
203		
204				// address from latlng
205				if(options.location_type=='latlng' && options.address !== undefined){
206					var latlngStr = options.address.split(",",2);
207					var lat = parseFloat(latlngStr[0]);
208					var lng = parseFloat(latlngStr[1]);
209					var latlng = new google.maps.LatLng(lat, lng);
210
211					geocoder.geocode({'latLng': latlng}, function(results, status) {
212						if (status == google.maps.GeocoderStatus.OK) {				
213							
214							let markerOptions = {
215				                map: map,
216				                position: latlng
217				            };
218
219				            if (options.iconURL && options.iconURL.trim() !== '') {
220				                var img = new Image();
221				                img.src = options.iconURL;
222
223				                img.onload = function () {
224				                    var imgWidth = img.width;
225				                    var imgHeight = img.height;
226
227				                    var customIcon = document.createElement('div');
228				                    customIcon.className = 'custom-marker';
229				                    customIcon.style.width = imgWidth + 'px';
230				                    customIcon.style.height = imgHeight + 'px';
231				                    customIcon.style.backgroundImage = `url(${options.iconURL})`;
232				                    customIcon.style.backgroundSize = 'cover';
233				                    customIcon.style.position = 'absolute';
234
235				                    markerOptions.content = customIcon;
236
237				                    const marker = new google.maps.marker.AdvancedMarkerElement(markerOptions);
238				                    map.setCenter(marker.position);
239				                };
240
241				                img.onerror = function () {
242				                    console.error("Error loading marker image: " + options.iconURL);
243				                    const marker = new google.maps.marker.AdvancedMarkerElement(markerOptions); // Default marker
244				                    map.setCenter(marker.position);
245				                };
246				            } else {
247				                // No custom icon, use default Google Maps marker
248				                const marker = new google.maps.marker.AdvancedMarkerElement(markerOptions);
249				                map.setCenter(marker.position);
250				            }
251
252						} else {				
253							document.getElementById(options.map_canvas_id).style.display='none';
254						}
255					});
256					
257				}else if(options.address==''){
258					//console.log('t');
259				}else{
260					geocoder.geocode( { 'address': options.address}, function(results, status) {
261						if (status == google.maps.GeocoderStatus.OK) {		
262							console.log('map '+results[0].geometry.location);
263							map.setCenter(results[0].geometry.location);
264							var marker = new google.maps.Marker({
265								map: map,
266								position: results[0].geometry.location,
267								icon: options.iconURL
268							});				
269							
270						} else {
271							document.getElementById(options.map_canvas_id).style.display='none';				
272						}
273					});
274				}
275
276				// mark as map drawn
277				$('#'+ options.map_canvas_id).addClass('mDrawn');
278			}
279		}
280
281
282		// INIT
283		code.init();		
284	};
285
286
287// trigger load google map on dynamic map element u4.6.1
288	$.fn.evo_load_gmap = function(opt){
289		var defs = {
290			'map_canvas_id':'',
291			'delay':0,
292			trigger_point:'',
293		};
294		var OO = $.extend({}, defs, opt);
295
296		EL = this;
297		EL_id = EL.attr('id');
298
299		if( ('map_canvas_id' in OO ) && OO.map_canvas_id != '' ) EL_id = OO.map_canvas_id;
300
301
302		var location_type = 'add';
303		var location_type = EL.data('location_type');
304
305		if(location_type=='add'){
306			var address = EL.data('address');				
307		}else{			
308			var address = EL.data('latlng');
309			var location_type = 'latlng';				
310		}
311		scrollwheel = EL.data('scroll') == 'yes'? true: false;
312
313		var elms = document.querySelectorAll("[id='"+EL_id+"']");
314
315		// check for unique id
316		if( elms.length > 1){
317			// GEN
318			maximum = 99;
319			minimum = 10;
320			var randomnumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
321			EL_id = EL_id+'_'+randomnumber;
322			EL.attr('id', EL_id);
323		}
324
325		// get delay
326			__delay = 0;
327			if( EL.data('delay') ) __delay = EL.data('delay');
328			if( OO.delay != 0 ) __delay = OO.delay;
329
330		//console.log(EL_id +' '+location_type);
331
332		// load the map
333		EL.evoGenmaps({
334			map_canvas_id: EL.attr('id'),
335			fnt: 5,
336			location_type:	location_type,
337			address: address,
338			zoomlevel: parseInt( EL.data('zoom') ),
339			mapformat: EL.data('mty'),
340			scroll: scrollwheel,
341			iconURL: ( EL.data('mapicon') !== undefined ? EL.data('mapicon') : '') ,
342			delay:  __delay,
343			trigger_point: OO.trigger_point,
344		});
345
346
347	};
348
349
350
351}(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.