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); 9/*umsLeafletMarker.prototype.init = function() { 10 this._ignoreBaseInfoWndBind = true; 11 umsLeafletMarker.superclass.init.apply(this, arguments); 12};*/ 13umsLeafletMarker.prototype._createMarkerObj = function () { 14 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]; 15 16 var opts = { 17 draggable: this._markerParams.draggable, 18 }; 19 if (this._markerParams.icon) { 20 this._createIcon(this._markerParams.icon); 21 opts.icon = this._iconObj; 22 } 23 var marker = L.marker(pos, opts).addTo(this._map.getRawMapInstance()); 24 25 return marker; 26}; 27umsLeafletMarker.prototype.addToMap = function () { 28 this._markerObj.addTo(this._map.getRawMapInstance()); 29}; 30umsLeafletMarker.prototype._setAnchor = function (iconWidth, iconHeight) { 31 //console.log(iconWidth, iconHeight); 32 /*this._markerObj.setOptions({ 33 anchor: new Microsoft.Maps.Point(0, -iconHeight) 34 });*/ 35 //console.log('_setAnchor', iconWidth, iconHeight); 36}; 37/*umsLeafletMarker.prototype.setTitle = function(title, noRefresh) { 38 umsLeafletMarker.superclass.setTitle.apply(this, arguments); 39}; 40umsLeafletMarker.prototype.setDescription = function (description, noRefresh) { 41 umsLeafletMarker.superclass.setTitle.apply(this, arguments); 42};*/ 43umsLeafletMarker.prototype.setVisible = function (state) { 44 if (state) { 45 this._markerObj.setOpacity(1); 46 this._markerObj.opacity = 1; 47 } else { 48 this._markerObj.setOpacity(0); 49 this._markerObj.opacity = 0; 50 this._markerObj.closePopup(); 51 } 52}; 53umsLeafletMarker.prototype.getPosition = function () { 54 var loc = this._markerObj.getLatLng(); 55 return { lat: loc.lat, lng: loc.lng }; 56}; 57umsLeafletMarker.prototype.setPosition = function (lat, lng) { 58 this._markerObj.setLatLng([lat, lng]); 59}; 60umsLeafletMarker.prototype.lat = function () { 61 var loc = this._markerObj.getLatLng(); 62 return loc.lat; 63}; 64umsLeafletMarker.prototype.lng = function () { 65 var loc = this._markerObj.getLatLng(); 66 return loc.lng; 67}; 68umsLeafletMarker.prototype.removeFromMap = function () { 69 this._markerObj.removeFrom(this._map.getRawMapInstance()); 70}; 71umsLeafletMarker.prototype._setInfoWndContent = function (withOpenPopup) { 72 if (!this._infoWindow) { 73 var offsetH = 0; 74 if (this._markerParams && this._markerParams.icon_data && this._markerParams.icon_data.width && this._markerParams.icon_data.height) { 75 offsetH = -1 * parseInt(this._markerParams.icon_data.height); 76 //opts.iconSize = [parseInt(this._markerParams.icon_data.width), parseInt(this._markerParams.icon_data.height)]; 77 } 78 this._infoWindow = new L.popup({ 79 // TODO: Make this offset - to depends from marker icon size 80 offset: L.point(0, offsetH), 81 }); 82 this._markerObj.bindPopup(this._infoWindow); // add popups 83 } 84 var description = this._markerParams.description ? this._markerParams.description.replace(/\n/g, '<br/>') : false, 85 title = this._markerParams.title ? this._markerParams.title : false, 86 content = (title ? '<h3 class="umsMarkerTitle">' + title + '</h3>' : '') + (description ? '<div class="umsMarkerDesc">' + description + '</div>' : ''); 87 88 this._infoWindow.setContent(content); 89 this._infoWindow.update(); 90 if (withOpenPopup) { 91 this._infoWndOpened = true; 92 this._markerObj.openPopup(); 93 } 94}; 95/*umsLeafletMarker.prototype.refreshInfoWnd = function() { 96 97};*/ 98umsLeafletMarker.prototype._updateInfoWndContent = function (withOpenPopup) { 99 this._setInfoWndContent(withOpenPopup); 100 this._infoWndWasInited = true; 101}; 102umsLeafletMarker.prototype.addEventListener = function (event, callback) { 103 this._markerObj.on(event, callback); 104}; 105umsLeafletMarker.prototype._openInfoWnd = function (withOpenPopup) { 106 this._setInfoWndContent(withOpenPopup); 107}; 108umsLeafletMarker.prototype.directOpenInfoWnd = function () { 109 if (this._infoWindow) { 110 this._markerObj.openPopup(); 111 } else this._setInfoWndContent(); 112}; 113umsLeafletMarker.prototype._closeInfoWnd = function () { 114 if (this._infoWindow.isPopupOpen()) { 115 this._markerObj.closePopup(); 116 } 117}; 118umsLeafletMarker.prototype.getIcon = function () { 119 return this._markerObj.getIcon(); 120}; 121umsLeafletMarker.prototype.setIcon = function (iconPath) { 122 this._createIcon(iconPath); 123 this._markerObj.setIcon(this._iconObj); 124}; 125umsLeafletMarker.prototype._createIcon = function (iconPath) { 126 var opts = { 127 iconUrl: iconPath, 128 }; 129 if (this._markerParams.icon_data) { 130 this._markerParams.icon_data.width = this._markerParams.icon_data.width ? parseInt(this._markerParams.icon_data.width) : false; 131 this._markerParams.icon_data.height = this._markerParams.icon_data.height ? parseInt(this._markerParams.icon_data.height) : false; 132 if (this._markerParams.icon_data.width && this._markerParams.icon_data.height) { 133 opts.iconSize = [this._markerParams.icon_data.width, this._markerParams.icon_data.height]; 134 opts.iconAnchor = [this._markerParams.icon_data.width / 2, this._markerParams.icon_data.height]; 135 } 136 } 137 this._iconObj = L.icon(opts); 138}; 139umsLeafletMarker.prototype.showInfoWnd = function (forceUpdateInfoWnd, forceShow, withOpenPopup) { 140 if (this._infoWindow) { 141 this._infoWndOpened = this._infoWindow.isOpen(); 142 } 143 umsLeafletMarker.superclass.showInfoWnd.apply(this, arguments); 144};
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.