PageSourceSearch

https://wyomingdra.com/wp-content/plugins/google-maps-easy/modules/marker/js/core.marker.js?ver=1.11.12

js wyomingdra.com collected 2026-10-04 00:26:26 UTC 13,187 bytes, 385 lines download raw bytes

1// Markers
2function gmpGoogleMarker(map, params) {
3	this._map = map;
4	this._markerObj = null;
5	var defaults = {
6		// Empty for now
7	};
8	if(!params.position && params.coord_x && params.coord_y) {
9		params.position = new google.maps.LatLng(params.coord_x, params.coord_y);
10	}
11	this._markerParams = jQuery.extend({}, defaults, params);
12	this._markerParams.map = this._map.getRawMapInstance();
13	//this._id = params.id ? params.id : 0;
14	this._infoWindow = null;
15	this._infoWndOpened = false;
16	this._infoWndWasInited = false;
17	this._infoWndDirectionsBtn = false;
18	this._infoWndPrintBtn = false;
19	this._mapDragScroll = {
20		scrollwheel: null
21	};
22	this.init();
23}
24gmpGoogleMarker.prototype.infoWndOpened = function() {
25	return this._infoWndOpened;
26};
27gmpGoogleMarker.prototype.init = function() {
28	var markerParamsForCreate = this._markerParams
29	,	openInfoWndEvent = 'click'
30	,	closeInfoWndEvent = ''
31	,	openLinkEvent = 'click';
32
33	if(parseInt(this._map._mapParams.hide_marker_tooltip)) {
34		this._markerParams.marker_title = this._markerParams.title;
35		delete markerParamsForCreate.title;
36	}
37	this._markerObj = new google.maps.Marker( markerParamsForCreate );
38	if(this._markerParams.dragend) {
39		this._markerObj.addListener('dragend', jQuery.proxy(this._markerParams.dragend, this));
40	}
41	if(this._markerParams.click) {
42		this._markerObj.addListener('click', jQuery.proxy(this._markerParams.click, this));
43	}
44	this._markerObj.addListener('domready', jQuery.proxy(function(){
45		changeInfoWndBgColor(this._map);
46	}, this));
47	if(this._markerParams.params && !(window.ontouchstart === null || navigator.msMaxTouchPoints)) {
48		if(parseInt(this._markerParams.params.description_mouse_hover)) {
49			openInfoWndEvent = 'mouseover';
50			if(parseInt(this._markerParams.params.description_mouse_leave)) {
51				closeInfoWndEvent = 'mouseout';
52			}
53		}
54	}
55	this._markerObj.addListener(openInfoWndEvent, jQuery.proxy(function () {
56		if(this._markerParams.params
57			&& !parseInt(this._markerParams.params.description_mouse_hover)
58			&& parseInt(this._markerParams.params.marker_link)
59		) {
60			return;
61		} else {
62			this.showInfoWnd();
63		}
64        jQuery(document).trigger('gmapAfterMarkerClick', this);
65	}, this));
66	if(closeInfoWndEvent) {
67		this._markerObj.addListener(closeInfoWndEvent, jQuery.proxy(function () {
68			var self = this
69			,	infoWndDiv = jQuery('.gm-style-iw').parent()
70			,	timeout = 300;
71
72			infoWndDiv.on('mouseover', function () {
73				// Mouse is on infowindow content
74				infoWndDiv.addClass('hovering');
75			});
76			infoWndDiv.on('mouseleave', function () {
77				// Hide infowindow after mouse have left infowindow content
78				setTimeout(function() {
79					self.hideInfoWnd();
80				}, timeout);
81			});
82			setTimeout(function() {
83				// Hide infowindow if mouse is not on infowindow content
84				if(!infoWndDiv.hasClass('hovering')) {
85					self.hideInfoWnd();
86				}
87			}, timeout);
88		}, this));
89	}
90	if(this._markerParams.params && parseInt(this._markerParams.params.marker_link)) {
91		this._markerObj.addListener(openLinkEvent, jQuery.proxy(function () {
92			var isLink = /http/gi
93			,	markerLink = !this._markerParams.params.marker_link_src.match(isLink)
94					? 'http://' + this._markerParams.params.marker_link_src
95					: this._markerParams.params.marker_link_src;
96
97			if(parseInt(this._markerParams.params.marker_link_new_wnd)) {
98				window.open(markerLink,	'_blank');
99			} else {
100				location.href = markerLink;
101			}
102		}, this));
103	}
104};
105gmpGoogleMarker.prototype.showInfoWnd = function( forceUpdateInfoWnd, forceShow ) {
106	var allShapes = this._map.getAllShapes();
107	if(allShapes && allShapes.length) {
108		for(var i = 0; i < allShapes.length; i++) {
109			if(allShapes[i]._infoWndOpened) allShapes[i].hideInfoWnd();
110		}
111	}
112	if(!this._infoWndWasInited || forceUpdateInfoWnd) {
113		this._updateInfoWndContent();
114		this._infoWndWasInited = true;
115	}
116	if(this._infoWindow && !this._infoWndOpened) {
117		var allMapMArkers = this._map.getAllMarkers();
118		// Google Maps Javascript API v3 allows to open several infowindows on map
119		if(allMapMArkers && allMapMArkers.length > 1 && !forceShow) {
120			for(var i = 0; i < allMapMArkers.length; i++) {
121				allMapMArkers[i].hideInfoWnd();
122			}
123		}
124		if(parseInt(this.getMap().getParam('center_on_cur_marker_infownd')) && !GMP_DATA.isAdmin) {
125			this.getMap().setCenter(this.getMarkerParam('position'));
126		}
127		if(this._map.getParam('marker_infownd_type') == 'slide' && (typeof(this.showInfoWndSlide) == 'function')) {
128			this.showInfoWndSlide();
129		} else {
130			this._infoWindow.open(this._map.getRawMapInstance(), this._markerObj);
131		}
132		this._infoWndOpened = true;
133	}
134};
135gmpGoogleMarker.prototype.hideInfoWnd = function() {
136	if(this._infoWindow && this._infoWndOpened) {
137		this._infoWindow.close();
138		this._infoWndOpened = false;
139
140		var googleMap = this._map.getRawMapInstance();
141		googleMap.setOptions( {scrollwheel: this._mapDragScroll.scrollwheel} );
142
143		jQuery(document).trigger('gmapAfterHideInfoWnd', this);
144	}
145};
146gmpGoogleMarker.prototype.getRawMarkerInstance = function() {
147	return this._markerObj;
148};
149gmpGoogleMarker.prototype.getRawMarkerParams = function() {
150	return this._markerParams;
151};
152gmpGoogleMarker.prototype.getIcon = (function() {
153	return this._markerObj.getIcon();
154});
155gmpGoogleMarker.prototype.setIcon = function(iconPath) {
156	this._markerObj.setIcon( iconPath );
157};
158gmpGoogleMarker.prototype.setTitle = function(title, noRefresh) {
159	if(!parseInt(this._map._mapParams.hide_marker_tooltip))
160		this._markerObj.setTitle( title );
161	this._markerParams.title = title;
162	if(!noRefresh)
163		this._updateInfoWndContent();
164};
165gmpGoogleMarker.prototype.getTitle = function() {
166	return typeof this._markerParams.title != 'undefined' ? this._markerParams.title : this._markerParams.marker_title;
167};
168gmpGoogleMarker.prototype.getPosition = function() {
169	return this._markerObj.getPosition();
170};
171gmpGoogleMarker.prototype.setPosition = function(lat, lng) {
172	this._markerObj.setPosition( new google.maps.LatLng(lat, lng) );
173};
174gmpGoogleMarker.prototype.lat = function() {
175	return this.getPosition().lat();
176};
177gmpGoogleMarker.prototype.lng = function(lng) {
178	return this.getPosition().lng();
179};
180gmpGoogleMarker.prototype.setId = function(id) {
181	this._markerParams.id = id;
182};
183gmpGoogleMarker.prototype.getId = function() {
184	return this._markerParams.id;
185};
186gmpGoogleMarker.prototype.setDescription = function (description, noRefresh) {
187	this._markerParams.description = description;
188	if(!noRefresh)
189		this._updateInfoWndContent();
190	if(this._markerParams.params && parseInt(this._markerParams.params.show_description)) {
191		this.showInfoWnd(false, true);
192	}
193};
194gmpGoogleMarker.prototype.getDescription = function () {
195	return this._markerParams.description;
196};
197gmpGoogleMarker.prototype._setTitleColor = function(titleDiv) {
198	var titleColor = this._map.getParam('marker_title_color');
199
200	if(titleColor && titleColor != '') {
201		titleDiv.css({
202			'color': titleColor
203		});
204	}
205	return titleDiv;
206};
207gmpGoogleMarker.prototype._setTitleSize = function(titleDiv) {
208	var titleSize = this._map.getParam('marker_title_size')
209	,	titleSizeUnits = this._map.getParam('marker_title_size_units');
210
211	if(titleSize && titleSizeUnits && titleSize != '') {
212		titleDiv.css({
213			'font-size': titleSize + titleSizeUnits
214		,	'line-height': (+titleSize + 5) + titleSizeUnits
215		});
216	}
217	return titleDiv;
218};
219gmpGoogleMarker.prototype._setDescSize = function(descDiv) {
220	var descSize = this._map.getParam('marker_desc_size')
221	,	descSizeUnits = this._map.getParam('marker_desc_size_units');
222
223	if(descSize && descSizeUnits && descSize != '') {
224		descDiv.css({
225			'font-size': descSize + descSizeUnits
226		,	'line-height': parseInt(descSize) + 5 + descSizeUnits
227		});
228	}
229	return descDiv;
230};
231gmpGoogleMarker.prototype._updateInfoWndContent = function() {
232	var contentStr = jQuery('<div/>', {})
233	,	description = this._markerParams.description ? this._markerParams.description.replace(/\n/g, '<br/>') : false
234	,	title = this._markerParams.title ? this._markerParams.title : false;
235
236	if(parseInt(this._map._mapParams.hide_marker_tooltip) && !GMP_DATA.isAdmin) {
237		title = this._markerParams.marker_title ? this._markerParams.marker_title : false;
238	}
239	if(title) {
240		var titleDiv = jQuery('<div/>', {})
241			.addClass('gmpInfoWindowtitle')
242			.html( title );
243
244		titleDiv = this._setTitleColor(titleDiv);
245		titleDiv = this._setTitleSize(titleDiv);
246		contentStr.append( titleDiv );
247
248		if(this._infoWndDirectionsBtn) {
249			this._infoWndDirectionsBtn.insertAfter(contentStr.find('.gmpInfoWindowtitle'));
250		}
251		if(this._infoWndPrintBtn) {
252			this._infoWndPrintBtn.insertAfter(contentStr.find('.gmpInfoWindowtitle'));
253		}
254	}
255	if(description) {
256		var descDiv = jQuery('<div/>', {})
257			.addClass('egm-marker-iw')
258			.html( description );
259
260		descDiv = this._setDescSize(descDiv);
261		contentStr.append( descDiv );
262
263		// Check scripts in description, and execute them if they are there
264		var $scripts = contentStr.find('script');
265		if($scripts && $scripts.length) {
266			$scripts.each(function(){
267				var scriptSrc = jQuery(this).attr('src');
268				if(scriptSrc && scriptSrc != '') {
269					jQuery.getScript( scriptSrc );
270				}
271			});
272		}
273	}
274	this._setInfoWndContent( contentStr );
275};
276/**
277 * Just mark it as closed
278 */
279gmpGoogleMarker.prototype._setInfoWndClosed = function() {
280	this._infoWndOpened = false;
281	jQuery(document).trigger('gmapAfterHideInfoWnd', this);
282};
283gmpGoogleMarker.prototype._setInfoWndContent = function(newContentHtmlObj) {
284	var self = this
285	,	map = this.getMap();
286
287	if(!this._infoWindow) {
288		var mapWidth = GMP_DATA.isAdmin ? jQuery('#gmpMapPreview').width() : jQuery('#' + map.getViewHtmlId()).width()
289		,	infoWndType = map.getParam('marker_infownd_type')
290		,	infoWndWidth = map.getParam('marker_infownd_width_units') == 'px' ? map.getParam('marker_infownd_width') : mapWidth - 20
291		,	infoWndHeight = map.getParam('marker_infownd_height_units') == 'px' ? map.getParam('marker_infownd_height')+ 'px' : false
292		,	maxWndWidth = mapWidth * 0.6
293		,	infoWndParams = { maxWidth: infoWndWidth < maxWndWidth ? infoWndWidth : maxWndWidth };
294
295		switch(infoWndType) {
296			case 'rounded_edges':
297				infoWndParams.pixelOffset = new google.maps.Size(0, 10);
298				break;
299			default:
300				break;
301		}
302
303		//add disableAutoPan property if description_mouse_leave is true
304		/*if(this._markerParams.params && this._markerParams.params.description_mouse_leave)
305			infoWndParams['disableAutoPan'] = true;*/
306
307		this._infoWindow = new google.maps.InfoWindow(infoWndParams);
308
309		google.maps.event.addListener(this._infoWindow, 'domready', function(){
310			changeInfoWndType(map);
311			changeInfoWndBgColor(map);
312			// check if tooltip text has "Gallery by Supsystic"
313			if(this.content && this.content.innerHTML && this.content.innerHTML.indexOf && this.content.innerHTML.indexOf('id="grid-gallery-') != -1) {
314				jQuery(document).trigger('ggFirInitialize');
315			}
316		});
317		google.maps.event.addListener(this._infoWindow, 'closeclick', function(){
318			self._setInfoWndClosed();
319		});
320	}
321	if(infoWndHeight) {
322		newContentHtmlObj.css('cssText', 'max-height: '+ infoWndHeight +';');
323	}
324
325	// Fix bug in FF - scroll on infowindow content changes map zoom
326	var scrollwheel = map.get('scrollwheel')
327	,	googleMap = map.getRawMapInstance();
328
329	//Save scrollwheel setting to container before rewrite it.
330	this._mapDragScroll.scrollwheel = scrollwheel;
331
332	newContentHtmlObj.hover(
333		function() {
334			googleMap.setOptions({ scrollwheel: false });
335		},
336		function() {
337			googleMap.setOptions({ scrollwheel: scrollwheel });
338		}
339	);
340	this._infoWindow.setContent(newContentHtmlObj[0]);
341};
342gmpGoogleMarker.prototype.removeFromMap = function() {
343	this.getRawMarkerInstance().setMap( null );
344};
345gmpGoogleMarker.prototype.setMarkerParams = function(params) {
346	this._markerParams = params;
347	return this;
348};
349gmpGoogleMarker.prototype.setMarkerParam = function(key, value) {
350	this._markerParams[ key ] = value;
351	return this;
352};
353gmpGoogleMarker.prototype.getMarkerParam = function(key) {
354	return this._markerParams[ key ];
355};
356gmpGoogleMarker.prototype.setMap = function( map ) {
357	this.getRawMarkerInstance().setMap( map );
358};
359gmpGoogleMarker.prototype.getMap = function() {
360	return this._map;
361};
362gmpGoogleMarker.prototype.setVisible = function(state) {
363	this.getRawMarkerInstance().setVisible(state);
364}
365gmpGoogleMarker.prototype.getVisible = function(state) {
366	this.getRawMarkerInstance().getVisible(state);
367}
368// Common functions
369function _gmpPrepareMarkersList(markers, params) {
370	params = params || {};
371	if(markers) {
372		for(var i = 0; i < markers.length; i++) {
373			markers[i].coord_x = parseFloat( markers[i].coord_x );
374			markers[i].coord_y = parseFloat( markers[i].coord_y );
375			markers[i].icon = markers[i].icon_data.path;
376			if(params.dragend) {
377				markers[i].draggable = true;
378				markers[i].dragend = params.dragend;
379			}
380		}
381	}
382	return markers;
383}
384
385window.gmpGoogleMarker = gmpGoogleMarker;

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.