PageSourceSearch

https://www.visitreykjanes.is/_moya/js/map/map.js?v=1790922283

js visitreykjanes.is collected 2026-10-02 07:10:42 UTC 5,374 bytes, 204 lines download raw bytes

1//moya.map = window.moya.map || {};
2if (typeof moya === 'undefined') moya = {};
3moya.map = (function () {
4	"use strict";
5	var createMap = function ($element, options) {
6
7		},
8		createMapFromSelector = function (selector, options) {
9			var $element = $(selector);
10			if ($element.length > 0) {
11				if (options.autoCenter === undefined) {
12					options.autoCenter = true;
13				}
14				moya.map.createMap($element, options);
15			}
16		},
17		createMapFromStatic = function ($element) {
18			var $img = $element.find('img.moyaStaticMap').first();
19			if ($img.length == 1) {
20				var src = $img.attr('src');
21				var x = parseQuery(src);
22				$img.remove();
23				return moya.map.createMap($element, {
24					center: getLatLng(x.center),
25					markers: [createMarkerOptions(x.center)]
26				});
27			}
28			return null;
29		},
30		createMapFromList = function (listSelector, parentWrapSelector, opts) {
31			if (!opts) {
32				opts = {};
33			}
34			if (opts.autoCenter === undefined) {
35				opts.autoCenter = true;
36			}
37			var markerOpts = (opts.markerOptions) ? opts.markerOptions : {};
38			var $listWrap = $(listSelector);
39			var $parentWrap = $(parentWrapSelector);
40
41			var markers = [];
42			$listWrap.children().each(function () {
43				var markerOption = createMarkerOptionsFromItem($(this), markerOpts);
44				if (markerOption) {
45					markers.push(markerOption);
46				}
47			});
48			if (markers.length > 0) {
49				opts.markers = markers;
50			}
51			moya.map.createMap($parentWrap, opts);
52		},
53
54		createMarkerOptions = function (opts, context) {
55			var t = typeof opts;
56			var ret = {};
57			if (t == 'string') {
58				ret.position = getLatLng(opts);
59			}
60			else if (t == 'object') {
61				$.extend(ret, opts, {});
62			}
63			if (ret.optionsPrepare && window[ret.optionsPrepare] && typeof window[ret.optionsPrepare] == 'function') {
64				var f = window[ret.optionsPrepare];
65				var tmp = f(ret, context);
66				if (tmp) {
67					ret = tmp;
68				}
69			}
70			if (ret.position && 'string' == typeof ret.position) {
71				ret.position = getLatLng(ret.position);
72			}
73			return ret;
74		},
75		getLatLng = function (s) {
76			if (!s) return null;
77			var l = s.split(',');
78			return moya.map.createLatLng(Number(l[0]), Number(l[1]));
79		},
80		createLatLng = function (lat, lng) {
81			return [lat, lng];
82		},
83		getLatLngString = function (pos) {
84			return pos.lat() + ',' + pos.lng();
85		},
86		getMapOptions = function (otherOptions) {
87			var ret = $.extend(true, moya.map.getDefaultOptions(), otherOptions);
88			if (ret.center && 'string' == typeof ret.center) {
89				ret.center = getLatLng(ret.center);
90			}
91			return ret;
92		},
93		getDefaultOptions = function () {
94			return {}
95		},
96		findMarkers = function ($list, opts) {
97			var ret = [];
98			$list.each(function () {
99				var marker = createMarkerOptionsFromItem($(this), opts);
100				if (marker) {
101					ret.push(marker);
102				}
103			});
104			return ret;
105		},
106		createMarkerOptionsFromItem = function ($item, opts) {
107			var ret = null;
108			var loc = $item.data('location');
109			if (!opts) opts = {};
110
111			var titleSelector = (opts.titleSelector) ? opts.titleSelector : '.title';
112			if (loc) {
113				ret = createMarkerOptions(opts, $item);
114
115				ret.position = getLatLng(loc);
116				ret.title = $item.find(titleSelector).text();
117				ret.info = $($item.wrap()[0]).clone()[0];
118
119				var color = getMarkerColor($item);
120				if (opts.iconMapper && window[opts.iconMapper] && typeof window[opts.iconMapper] == 'function') {
121					var f = window[opts.iconMapper];
122					var icon = f($item);
123					if (icon) {
124						ret['icon'] = icon;
125					}
126				}
127				else if (color) {
128					ret["icon"] = getMarkerIconByColor(color);
129				}
130			}
131			return ret;
132		},
133		getMarkerIconByColor = function (color) {
134			return "http://maps.google.com/mapfiles/ms/icons/" + color + "-dot.png";
135		},
136		getMarkerColor = function ($card) {
137			var classes = $card.attr('class');
138			var ret = null;
139			var re = new RegExp(".*color-([a-z]+).*");
140			if (classes.match(re)) {
141				ret = classes.replace(re, '$1');
142			}
143			return ret;
144		},
145		parseQuery = function (qstr) {
146			var query = {};
147			var a = qstr.split('&');
148			for (var i in a) {
149				if (a.hasOwnProperty(i)) {
150					var b = a[i].split('=');
151					query[decodeURIComponent(b[0])] = decodeURIComponent(b[1]);
152				}
153			}
154
155			return query;
156		},
157		parseCurrent = function () {
158			return parseQuery(document.URL);
159		},
160		getMapElement = function ($parent, opts) {
161			var c = (opts.cssClass) ? opts.cssClass : 'map';
162			var $map = $parent.find('.map');
163			if ($map.length < 1) {
164				$map = $('<div class="map"></div>');
165				if (c) {
166					$map.addClass(c);
167				}
168				if (opts.css) {
169					$map.css(opts.css);
170				}
171				$parent.prepend($map);
172			}
173			if ($map.width() < 1) {
174				$map.css('width', '400px');
175			}
176			if ($map.height() < 1) {
177				$map.css('height', '300px');
178			}
179			return $map;
180		},
181
182		initEdit = function (selector, opts) {
183
184		}
185		;
186	return {
187		createMap: createMap,
188		createMapFromStatic: createMapFromStatic,
189		createMapFromSelector: createMapFromSelector,
190		createMapFromList: createMapFromList,
191		getLatLng: getLatLng,
192		createMarkerOptions: createMarkerOptions,
193		createMarkerOptionsFromCard: createMarkerOptionsFromItem,
194		findMarkers: findMarkers,
195		getMarkerColor: getMarkerColor,
196		parseCurrent: parseCurrent,
197		parseQuery: parseQuery,
198		initEdit: initEdit,
199		getMapOptions: getMapOptions,
200		createLatLng: createLatLng,
201		getMapElement: getMapElement,
202		getLatLngString: getLatLngString
203	}
204})();

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.