PageSourceSearch

https://www.nmact.org/wp-content/plugins/ultimate-maps-by-supsysti…/engines/core.leaflet.marker.js?ver=1.5.5

js nmact.org collected 2026-09-24 09:59:17 UTC 6,815 bytes, 176 lines download raw bytes

1function umsLeafletMarker(map, params) {
2  //this._$markerEl = null;
3  this._iconObj = null;
4
5  umsLeafletMarker.superclass.constructor.apply(this, arguments);
6  //this._mapEntryId = 0;
7}
8extendUms(umsLeafletMarker, umsBaseMarker);
9umsLeafletMarker._fixIconStylesPriority = function () {
10  if (typeof L === 'undefined' || !L.Icon || !L.Icon.prototype || L.Icon.prototype._umsFixIconStylesPriority) {
11    return;
12  }
13  var setIconStyles = L.Icon.prototype._setIconStyles;
14  if (typeof setIconStyles !== 'function') {
15    return;
16  }
17
18  L.Icon.prototype._setIconStyles = function (img, name) {
19    setIconStyles.call(this, img, name);
20
21    var options = this.options,
22      size = L.point(options[name === 'shadow' ? 'shadowSize' : 'iconSize']),
23      anchor =
24        name === 'shadow' && options.shadowAnchor
25          ? L.point(options.shadowAnchor)
26          : options.iconAnchor
27            ? L.point(options.iconAnchor)
28            : size
29              ? size.divideBy(2, true)
30              : null;
31
32    if (anchor) {
33      img.style.setProperty('margin-left', -anchor.x + 'px', 'important');
34      img.style.setProperty('margin-top', -anchor.y + 'px', 'important');
35    }
36  };
37  L.Icon.prototype._umsFixIconStylesPriority = true;
38};
39/*umsLeafletMarker.prototype.init = function() {
40	this._ignoreBaseInfoWndBind = true;
41	umsLeafletMarker.superclass.init.apply(this, arguments);
42};*/
43umsLeafletMarker.prototype._createMarkerObj = function () {
44  var pos = this._markerParams.position && typeof this._markerParams.coord_x === 'undefined' ? [this._markerParams.position.lat, this._markerParams.position.lng] : [this._markerParams.coord_x, this._markerParams.coord_y];
45
46  var opts = {
47    draggable: this._markerParams.draggable,
48  };
49  if (this._markerParams.icon) {
50    this._createIcon(this._markerParams.icon);
51    opts.icon = this._iconObj;
52  }
53  var marker = L.marker(pos, opts).addTo(this._map.getRawMapInstance());
54
55  return marker;
56};
57umsLeafletMarker.prototype.addToMap = function () {
58  this._markerObj.addTo(this._map.getRawMapInstance());
59};
60umsLeafletMarker.prototype._setAnchor = function (iconWidth, iconHeight) {
61  //console.log(iconWidth, iconHeight);
62  /*this._markerObj.setOptions({
63		anchor: new Microsoft.Maps.Point(0, -iconHeight)
64	});*/
65  //console.log('_setAnchor', iconWidth, iconHeight);
66};
67/*umsLeafletMarker.prototype.setTitle = function(title, noRefresh) {
68	umsLeafletMarker.superclass.setTitle.apply(this, arguments);
69};
70umsLeafletMarker.prototype.setDescription = function (description, noRefresh) {
71	umsLeafletMarker.superclass.setTitle.apply(this, arguments);
72};*/
73umsLeafletMarker.prototype.setVisible = function (state) {
74  if (state) {
75    this._markerObj.setOpacity(1);
76    this._markerObj.opacity = 1;
77  } else {
78    this._markerObj.setOpacity(0);
79    this._markerObj.opacity = 0;
80    this._markerObj.closePopup();
81  }
82};
83umsLeafletMarker.prototype.getPosition = function () {
84  var loc = this._markerObj.getLatLng();
85  return { lat: loc.lat, lng: loc.lng };
86};
87umsLeafletMarker.prototype.setPosition = function (lat, lng) {
88  this._markerObj.setLatLng([lat, lng]);
89};
90umsLeafletMarker.prototype.lat = function () {
91  var loc = this._markerObj.getLatLng();
92  return loc.lat;
93};
94umsLeafletMarker.prototype.lng = function () {
95  var loc = this._markerObj.getLatLng();
96  return loc.lng;
97};
98umsLeafletMarker.prototype.removeFromMap = function () {
99  this._markerObj.removeFrom(this._map.getRawMapInstance());
100};
101umsLeafletMarker.prototype._setInfoWndContent = function (withOpenPopup) {
102  if (!this._infoWindow) {
103    var offsetH = 0;
104    if (this._markerParams && this._markerParams.icon_data && this._markerParams.icon_data.width && this._markerParams.icon_data.height) {
105      offsetH = -1 * parseInt(this._markerParams.icon_data.height);
106      //opts.iconSize = [parseInt(this._markerParams.icon_data.width), parseInt(this._markerParams.icon_data.height)];
107    }
108    this._infoWindow = new L.popup({
109      // TODO: Make this offset - to depends from marker icon size
110      offset: L.point(0, offsetH),
111    });
112    this._markerObj.bindPopup(this._infoWindow); // add popups
113  }
114  var description = this._markerParams.description ? this._markerParams.description.replace(/\n/g, '<br/>') : false,
115    title = this._markerParams.title ? this._markerParams.title : false,
116    content = (title ? '<h3 class="umsMarkerTitle">' + title + '</h3>' : '') + (description ? '<div class="umsMarkerDesc">' + description + '</div>' : '');
117
118  this._infoWindow.setContent(content);
119  this._infoWindow.update();
120  if (withOpenPopup) {
121    this._infoWndOpened = true;
122    this._markerObj.openPopup();
123  }
124};
125/*umsLeafletMarker.prototype.refreshInfoWnd = function() {
126
127};*/
128umsLeafletMarker.prototype._updateInfoWndContent = function (withOpenPopup) {
129  this._setInfoWndContent(withOpenPopup);
130  this._infoWndWasInited = true;
131};
132umsLeafletMarker.prototype.addEventListener = function (event, callback) {
133  this._markerObj.on(event, callback);
134};
135umsLeafletMarker.prototype._openInfoWnd = function (withOpenPopup) {
136  this._setInfoWndContent(withOpenPopup);
137};
138umsLeafletMarker.prototype.directOpenInfoWnd = function () {
139  if (this._infoWindow) {
140    this._markerObj.openPopup();
141  } else this._setInfoWndContent();
142};
143umsLeafletMarker.prototype._closeInfoWnd = function () {
144  if (this._infoWindow.isPopupOpen()) {
145    this._markerObj.closePopup();
146  }
147};
148umsLeafletMarker.prototype.getIcon = function () {
149  return this._markerObj.getIcon();
150};
151umsLeafletMarker.prototype.setIcon = function (iconPath) {
152  this._createIcon(iconPath);
153  this._markerObj.setIcon(this._iconObj);
154};
155umsLeafletMarker.prototype._createIcon = function (iconPath) {
156  umsLeafletMarker._fixIconStylesPriority();
157
158  var opts = {
159    iconUrl: iconPath,
160  };
161  if (this._markerParams.icon_data) {
162    this._markerParams.icon_data.width = this._markerParams.icon_data.width ? parseInt(this._markerParams.icon_data.width) : false;
163    this._markerParams.icon_data.height = this._markerParams.icon_data.height ? parseInt(this._markerParams.icon_data.height) : false;
164    if (this._markerParams.icon_data.width && this._markerParams.icon_data.height) {
165      opts.iconSize = [this._markerParams.icon_data.width, this._markerParams.icon_data.height];
166      opts.iconAnchor = [this._markerParams.icon_data.width / 2, this._markerParams.icon_data.height];
167    }
168  }
169  this._iconObj = L.icon(opts);
170};
171umsLeafletMarker.prototype.showInfoWnd = function (forceUpdateInfoWnd, forceShow, withOpenPopup) {
172  if (this._infoWindow) {
173    this._infoWndOpened = this._infoWindow.isOpen();
174  }
175  umsLeafletMarker.superclass.showInfoWnd.apply(this, arguments);
176};

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.