PageSourceSearch

https://www.millertech.co.uk/wp-content/plugins/eventon-lite/assets/js/maps/eventon_gen_maps.js?ver=2.3.2

js millertech.co.uk collected 2026-10-09 23:08:03 UTC 9,033 bytes, 348 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							const {AdvancedMarkerElement} = await google.maps.importLibrary("marker");
215
216							const marker = new AdvancedMarkerElement({
217								map: map,
218								position: latlng,
219								icon: options.iconURL
220							});
221
222							var marker = new google.maps.Marker({
223								map: map,
224								position: latlng,
225								icon: options.iconURL
226							});
227							
228							//map.setCenter(results[0].geometry.location);
229							map.setCenter(marker.getPosition());
230							
231							*/
232
233							//console.log(options.iconURL);
234
235							const customIcon = document.createElement('div');
236							customIcon.className = 'custom-marker';
237
238							const marker = new google.maps.marker.AdvancedMarkerElement({
239							    map: map, 
240							    position: latlng, 
241							    //title: 'Marker Title', // Optional: Adds a tooltip on hover
242							   	// content: document.createElement('div'), // Optional: Custom marker HTML content
243							   	//content: customIcon
244							});
245							
246							//map.setCenter(results[0].geometry.location);
247							map.setCenter( marker.position );
248
249						} else {				
250							document.getElementById(options.map_canvas_id).style.display='none';
251						}
252					});
253					
254				}else if(options.address==''){
255					//console.log('t');
256				}else{
257					geocoder.geocode( { 'address': options.address}, function(results, status) {
258						if (status == google.maps.GeocoderStatus.OK) {		
259							console.log('map '+results[0].geometry.location);
260							map.setCenter(results[0].geometry.location);
261							var marker = new google.maps.Marker({
262								map: map,
263								position: results[0].geometry.location,
264								icon: options.iconURL
265							});				
266							
267						} else {
268							document.getElementById(options.map_canvas_id).style.display='none';				
269						}
270					});
271				}
272
273				// mark as map drawn
274				$('#'+ options.map_canvas_id).addClass('mDrawn');
275			}
276		}
277
278
279		// INIT
280		code.init();		
281	};
282
283
284// trigger load google map on dynamic map element u4.6.1
285	$.fn.evo_load_gmap = function(opt){
286		var defs = {
287			'map_canvas_id':'',
288			'delay':0,
289			trigger_point:'',
290		};
291		var OO = $.extend({}, defs, opt);
292
293		//return;
294
295		EL = this;
296		EL_id = EL.attr('id');
297
298		if( ('map_canvas_id' in OO ) && OO.map_canvas_id != '' ) EL_id = OO.map_canvas_id;
299
300		var location_type = 'add';
301		var location_type = EL.data('location_type');
302
303		if(location_type=='add'){
304			var address = EL.data('address');				
305		}else{			
306			var address = EL.data('latlng');
307			var location_type = 'latlng';				
308		}
309		scrollwheel = EL.data('scroll') == 'yes'? true: false;
310
311		var elms = document.querySelectorAll("[id='"+EL_id+"']");
312
313		// check for unique id
314		if( elms.length > 1){
315			// GEN
316			maximum = 99;
317			minimum = 10;
318			var randomnumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
319			EL_id = EL_id+'_'+randomnumber;
320			EL.attr('id', EL_id);
321		}
322
323		// get delay
324			__delay = 0;
325			if( EL.data('delay') ) __delay = EL.data('delay');
326			if( OO.delay != 0 ) __delay = OO.delay;
327
328		console.log(EL_id);
329
330		// load the map
331		EL.evoGenmaps({
332			map_canvas_id: EL.attr('id'),
333			fnt: 5,
334			location_type:	location_type,
335			address: address,
336			zoomlevel: parseInt( EL.data('zoom') ),
337			mapformat: EL.data('mty'),
338			scroll: scrollwheel,
339			iconURL: ( EL.data('mapicon') !== undefined ? EL.data('mapicon') : '') ,
340			delay:  __delay,
341			trigger_point: OO.trigger_point,
342		});
343
344	};
345
346
347
348}(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.