PageSourceSearch

https://www.rsfeva.org/wp-content/plugins/eventON/assets/js/maps/eventon_gen_maps.js?ver=4.5.8

js rsfeva.org collected 2026-10-02 11:30:16 UTC 7,523 bytes, 290 lines download raw bytes

1/**
2 * EventON Generate Google Maps Function
3 * @version  4.2
4 */
5(function($){
6
7
8// ADD notes on how to run this after approval
9
10// map loader function 
11	$.fn.evoGenmaps = function(opt){
12
13		var defaults = {
14			delay:	0,
15			fnt:	1,
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		};
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		code = {	
38			init:function(){	
39
40				// set calendar for event
41				if( obj.closest('.ajde_evcal_calendar').length>0){
42					options.cal = obj.closest('.ajde_evcal_calendar');
43				}
44
45				
46				if( options.cal === undefined){
47					console.log('Cannot find the calendar'); return false;
48				}
49
50				code.process_SC();
51
52				// various methods to draw map
53					// multiple maps at same time
54					if(options.fnt==1){
55						code.load_gmap();
56					}
57					
58					if(options.fnt==2){
59						if(options.delay==0){	code.load_gmap();	}else{
60							setTimeout(code.load_gmap, options.delay, this);
61						}			
62					} 
63					if(options.fnt==3){	code.load_gmap();	}
64					
65					// gmaps on popup
66					if(options.fnt==4){
67						// check if gmaps should run
68						if( this.attr('data-gmtrig')=='1' && this.attr('data-gmap_status')!='null'){	
69							code.load_gmap();			
70						}	
71					}
72
73					// load map on specified elements directly
74					// eg. location archive page
75					if(options.fnt==5){
76						code.draw_map();
77					}
78			},
79			// add unique id for map area
80			process_unique_map_id: function(){
81				var map_element = obj.closest('.eventon_list_event').find('.evo_metarow_gmap');
82
83				if(map_element === undefined ) return false;
84
85				var old_map_canvas_id = map_element.attr('id');	
86				if(old_map_canvas_id === undefined) return false;
87
88				// GEN
89				maximum = 99;
90				minimum = 10;
91				var randomnumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
92
93				map_canvas_id = old_map_canvas_id+'_'+randomnumber;
94				map_element.attr('id', map_canvas_id).addClass('test');
95				
96				options.map_canvas_id = map_canvas_id;
97
98				return map_canvas_id;
99			},
100			process_SC: function(){
101				CAL = options.cal;
102				if( options.SC !== '') return;
103				if(CAL == '') return false;
104				options.SC = CAL.evo_shortcode_data();
105			},
106
107			// load google map
108			load_gmap: function(){
109				SC = options.SC;
110						
111				var ev_location = obj.find('.event_location_attrs');
112
113				var location_type = ev_location.attr('data-location_type');
114				if(location_type=='address'){
115					options.address = ev_location.attr('data-location_address');
116					options.location_type = 'add';
117				}else{			
118					options.address = ev_location.attr('data-latlng');
119					options.location_type = 'latlng';				
120				}
121
122
123
124				// marker icons
125				if( SC !== undefined && SC != '' &&  'mapiconurl' in SC) options.iconURL = SC.mapiconurl;
126
127				// make sure there is address present to draw map
128				if( options.address === undefined || options.address == '') return false;
129
130				map_canvas_id = code.process_unique_map_id();
131
132				if(!map_canvas_id || $('#'+map_canvas_id).length == 0) return false;
133
134				var zoom = SC.mapzoom;
135				options.zoomlevel = (typeof zoom !== 'undefined' && zoom !== false)? parseInt(zoom):12;				
136				options.scroll = SC.mapscroll;	
137				options.mapformat = SC.mapformat;	
138													
139				code.draw_map();
140			},
141
142			// final draw
143			draw_map: function(){
144
145				if(!options.map_canvas_id || $('#'+options.map_canvas_id).length == 0){
146					console.log( 'Map element with id missing in page'); return false;
147				}
148
149				// map styles
150				if( typeof gmapstyles !== 'undefined' && gmapstyles != 'default'){
151					options.styles = JSON.parse(gmapstyles);
152				}
153
154				geocoder = new google.maps.Geocoder();					
155				//var latlng = new google.maps.LatLng(45.524732, -122.677031);
156
157				var latlng = 0;
158				
159				if(options.scroll == 'false' || options.scroll == false){
160
161					var myOptions = {			
162						//center: latlng,	
163						mapTypeId: 	options.mapformat,	
164						zoom: 		options.zoomlevel,	
165						scrollwheel: false,
166						styles: options.styles,
167						zoomControl:true,
168						draggable:false
169					}
170				}else{
171					var myOptions = {	
172						//center: latlng,	
173						mapTypeId: options.mapformat,	
174						zoom: options.zoomlevel,
175						styles: options.styles,
176						zoomControl:true,
177						scrollwheel: true,
178					}
179				}
180
181				//console.log(myOptions);
182				//console.log(options);
183				
184				var map_canvas = document.getElementById(options.map_canvas_id);
185				map = new google.maps.Map(map_canvas, myOptions);
186		
187				// address from latlng
188				if(options.location_type=='latlng' && options.address !== undefined){
189					var latlngStr = options.address.split(",",2);
190					var lat = parseFloat(latlngStr[0]);
191					var lng = parseFloat(latlngStr[1]);
192					var latlng = new google.maps.LatLng(lat, lng);
193
194					geocoder.geocode({'latLng': latlng}, function(results, status) {
195						if (status == google.maps.GeocoderStatus.OK) {				
196							var marker = new google.maps.Marker({
197								map: map,
198								position: latlng,
199								icon: options.iconURL
200							});
201							//map.setCenter(results[0].geometry.location);
202							map.setCenter(marker.getPosition());
203
204						} else {				
205							document.getElementById(options.map_canvas_id).style.display='none';
206						}
207					});
208					
209				}else if(options.address==''){
210					//console.log('t');
211				}else{
212					geocoder.geocode( { 'address': options.address}, function(results, status) {
213						if (status == google.maps.GeocoderStatus.OK) {		
214							//console.log('map '+results[0].geometry.location);
215							map.setCenter(results[0].geometry.location);
216							var marker = new google.maps.Marker({
217								map: map,
218								position: results[0].geometry.location,
219								icon: options.iconURL
220							});				
221							
222						} else {
223							document.getElementById(options.map_canvas_id).style.display='none';				
224						}
225					});
226				}
227			}
228		}
229
230
231		// INIT
232		code.init();
233
234		
235	};
236
237// trigger map load on calendar
238// @since 4.2
239	$('body').on('evo_load_map_on_cals',function (){
240		
241		if( $('body').find('.ajde_evcal_calendar').length < 1 ) return;
242
243		$('body').find('.ajde_evcal_calendar').each(function(){
244			var el = $(this);
245			el.find('.desc_trig').each(function(index){
246				var self = this;
247				setTimeout(function(){
248					$(self).evoGenmaps({'fnt':2,'cal': el});
249				},index*600);					
250			});
251		});
252	});
253
254	// trigger load google map on dynamic map element
255	$.fn.evo_load_gmap = function(opt){
256		var defs = {
257			'map_canvas_id':'',
258			'delay':0,
259		};
260		var OO = $.extend({}, defs, opt);
261
262		EL = this;
263
264		var location_type = 'add';
265		var location_type = EL.data('location_type');
266
267		if(location_type=='add'){
268			var address = EL.data('address');				
269		}else{			
270			var address = EL.data('latlng');
271			var location_type = 'latlng';				
272		}
273		scrollwheel = EL.data('scroll') == 'yes'? true: false;
274
275		EL.evoGenmaps({
276			map_canvas_id: EL.attr('id'),
277			fnt: 5,
278			location_type:	location_type,
279			address: address,
280			zoomlevel: parseInt( EL.data('zoom') ),
281			mapformat: EL.data('mty'),
282			scroll: scrollwheel,
283			delay:  EL.data('delay') ? EL.data('delay') : OO.delay
284		});
285
286	};
287
288
289
290}(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.