1// Markers 2function umsBaseMarker(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._ignoreBaseInfoWndBind = false; 23 this.init(); 24} 25umsBaseMarker.prototype.infoWndOpened = function () { 26 return this._infoWndOpened; 27}; 28umsBaseMarker.prototype._createMarkerObj = function () { 29 // Marker object creation for inheritance - here 30 this._methodRedefineNotice('umsBaseMarker.prototype._createMarkerObj'); 31}; 32umsBaseMarker.prototype.init = function () { 33 this._markerObj = this._createMarkerObj(); 34 var openInfoWndEvent = 'click', 35 closeInfoWndEvent = '', 36 openLinkEvent = 'click'; 37 /*var markerParamsForCreate = this._markerParams 38 , openInfoWndEvent = 'click' 39 , closeInfoWndEvent = '' 40 , openLinkEvent = 'click'; 41 42 if(parseInt(this._map._mapParams.hide_marker_tooltip)) { 43 this._markerParams.marker_title = this._markerParams.title; 44 delete markerParamsForCreate.title; 45 } 46 this._markerObj = new google.maps.Marker( markerParamsForCreate ); 47 48 this._markerObj.addListener('domready', jQuery.proxy(function(){ 49 changeInfoWndBgColor(this._map); 50 }, this));*/ 51 if (this._markerParams.dragend) { 52 this.addEventListener('dragend', jQuery.proxy(this._markerParams.dragend, this)); 53 //this._markerObj.addListener('dragend', jQuery.proxy(this._markerParams.dragend, this)); 54 } 55 if (this._markerParams.click) { 56 this.addEventListener('click', jQuery.proxy(this._markerParams.click, this)); 57 } 58 if (!navigator.userAgent.match(/iPad|iPhone|iPod|Android|BlackBerry|webOS/i)) { 59 if (parseInt(this._map._mapParams.marker_hover)) { 60 this.addEventListener( 61 'mouseover', 62 jQuery.proxy(function () { 63 if (typeof this._markerObj.opacity == 'undefined' || this._markerObj.opacity == 1) { 64 this.showInfoWnd(); 65 jQuery(document).trigger('umsAfterMarkerClick', this); 66 } 67 }, this) 68 ); 69 } 70 } 71 // console.log( this._markerParams ); 72 if (this._markerParams.params && !(window.ontouchstart === null || navigator.msMaxTouchPoints)) { 73 if (parseInt(this._markerParams.params.description_mouse_hover)) { 74 openInfoWndEvent = 'mouseover'; 75 if (parseInt(this._markerParams.params.description_mouse_leave)) { 76 closeInfoWndEvent = 'mouseout'; 77 } 78 } 79 } 80 if (!this._ignoreBaseInfoWndBind) { 81 this.addEventListener( 82 openInfoWndEvent, 83 jQuery.proxy(function () { 84 if (this._markerParams.params && !parseInt(this._markerParams.params.description_mouse_hover) && parseInt(this._markerParams.params.marker_link)) { 85 return; 86 } else { 87 this.showInfoWnd(); 88 } 89 jQuery(document).trigger('umsAfterMarkerClick', this); 90 }, this) 91 ); 92 } 93 if (closeInfoWndEvent) { 94 // Don't exactly know - what to do with this code 95 /*this.addEventListener(closeInfoWndEvent, jQuery.proxy(function () { 96 var self = this 97 , infoWndDiv = jQuery('.gm-style-iw').parent() 98 , timeout = 300; 99 100 infoWndDiv.on('mouseover', function () { 101 // Mouse is on infowindow content 102 infoWndDiv.addClass('hovering'); 103 }); 104 infoWndDiv.on('mouseleave', function () { 105 // Hide infowindow after mouse have left infowindow content 106 setTimeout(function() { 107 self.hideInfoWnd(); 108 }, timeout); 109 }); 110 setTimeout(function() { 111 // Hide infowindow if mouse is not on infowindow content 112 if(!infoWndDiv.hasClass('hovering')) { 113 self.hideInfoWnd(); 114 } 115 }, timeout); 116 }, this));*/ 117 } 118 if (this._markerParams.params && parseInt(this._markerParams.params.marker_link)) { 119 this.addEventListener( 120 openLinkEvent, 121 jQuery.proxy(function () { 122 var url_string = window.location.href, 123 url = new URL(url_string), 124 tab = url.searchParams.get('tab'); 125 if (tab !== 'maps_edit') { 126 var isLink = /http/gi, 127 markerLink = !this._markerParams.params.marker_link_src.match(isLink) ? 'http://' + this._markerParams.params.marker_link_src : this._markerParams.params.marker_link_src; 128 129 if (parseInt(this._markerParams.params.marker_link_new_wnd)) { 130 window.open(markerLink, '_blank'); 131 } else { 132 location.href = markerLink; 133 } 134 } 135 }, this) 136 ); 137 } 138}; 139umsBaseMarker.prototype.addEventListener = function (event, callback) {
140 this._methodRedefineNotice('umsBaseMarker.prototype.addEventListener'); 141}; 142umsBaseMarker.prototype.showInfoWnd = function (forceUpdateInfoWnd, forceShow, withOpenPopup) { 143 /*var allShapes = this._map.getAllShapes(); 144 if(allShapes && allShapes.length) { 145 for(var i = 0; i < allShapes.length; i++) { 146 if(allShapes[i]._infoWndOpened) allShapes[i].hideInfoWnd(); 147 } 148 }*/ 149 if (!this._infoWndWasInited || forceUpdateInfoWnd) { 150 this._updateInfoWndContent(true); 151 this._infoWndWasInited = true; 152 } 153 if (this._infoWindow && !this._infoWndOpened) { 154 var allMapMArkers = this._map.getAllMarkers(); 155 if (allMapMArkers && allMapMArkers.length > 1 && !forceShow) { 156 for (var i = 0; i < allMapMArkers.length; i++) { 157 allMapMArkers[i].hideInfoWnd(); 158 } 159 } 160 this._openInfoWnd(withOpenPopup); 161 } 162 this._infoWndOpened = true; 163 if (!navigator.userAgent.match(/iPad|iPhone|iPod|Android|BlackBerry|webOS/i)) { 164 if (parseInt(this._map._mapParams.marker_hover)) { 165 this.directOpenInfoWnd(); 166 } 167 } 168}; 169umsBaseMarker.prototype._openInfoWnd = function (withOpenPopup) { 170 this._methodRedefineNotice('umsBaseMarker.prototype._openInfoWnd'); 171}; 172umsBaseMarker.prototype.directOpenInfoWnd = function () { 173 this._methodRedefineNotice('umsBaseMarker.prototype.directOpenInfoWnd'); 174}; 175umsBaseMarker.prototype._closeInfoWnd = function () { 176 this._methodRedefineNotice('umsBaseMarker.prototype._closeInfoWnd'); 177}; 178umsBaseMarker.prototype.hideInfoWnd = function () { 179 if (this._infoWindow && this._infoWndOpened) { 180 this._closeInfoWnd(); 181 this._infoWndOpened = false; 182 183 //var mapObj = this._map.getRawMapInstance(); 184 //mapObj.setOptions( {scrollwheel: this._mapDragScroll.scrollwheel} ); 185 186 //jQuery(document).trigger('umsAfterHideInfoWnd', this); 187 } 188}; 189umsBaseMarker.prototype.getRawMarkerInstance = function () { 190 return this._markerObj; 191}; 192umsBaseMarker.prototype.getRawMarkerParams = function () { 193 return this._markerParams; 194}; 195umsBaseMarker.prototype.getIcon = function () { 196 //return this._markerObj.getIcon(); 197 this._methodRedefineNotice('umsBaseMarker.prototype.getIcon'); 198}; 199umsBaseMarker.prototype.setIcon = function (iconPath) { 200 //this._markerObj.setIcon( iconPath ); 201 this._methodRedefineNotice('umsBaseMarker.prototype.setIcon'); 202}; 203umsBaseMarker.prototype.setIconSize = function (width, height) { 204 if (typeof this._markerParams.icon_data === 'undefined') { 205 this._markerParams.icon_data = {}; 206 } 207 this._markerParams.icon_data.width = width; 208 this._markerParams.icon_data.height = height; 209}; 210umsBaseMarker.prototype.setTitle = function (title, noRefresh) { 211 this._markerParams.title = title; 212 if (!noRefresh) this._updateInfoWndContent(); 213}; 214umsBaseMarker.prototype.getTitle = function () { 215 return this._markerParams.title; 216}; 217umsBaseMarker.prototype.getPosition = function () { 218 //return this._markerObj.getPosition(); 219 this._methodRedefineNotice('umsBaseMarker.prototype.getPosition'); 220}; 221umsBaseMarker.prototype.setPosition = function (lat, lng) { 222 //this._markerObj.setPosition( new google.maps.LatLng(lat, lng) ); 223 this._methodRedefineNotice('umsBaseMarker.prototype.setPosition'); 224}; 225umsBaseMarker.prototype.lat = function () { 226 //return this.getPosition().lat(); 227 this._methodRedefineNotice('umsBaseMarker.prototype.lat'); 228}; 229umsBaseMarker.prototype.lng = function (lng) { 230 //return this.getPosition().lng(); 231 this._methodRedefineNotice('umsBaseMarker.prototype.lng'); 232}; 233umsBaseMarker.prototype.setId = function (id) { 234 this._markerParams.id = id; 235}; 236umsBaseMarker.prototype.getId = function () { 237 return parseInt(this._markerParams.id); 238}; 239umsBaseMarker.prototype.setDescription = function (description, noRefresh) { 240 this._markerParams.description = description; 241 if (!noRefresh) this._updateInfoWndContent(); 242 if (this._markerParams.params && parseInt(this._markerParams.params.show_description)) { 243 this.showInfoWnd(false, true); 244 } 245}; 246umsBaseMarker.prototype.getDescription = function () { 247 return this._markerParams.description; 248}; 249umsBaseMarker.prototype._setTitleColor = function (titleDiv) { 250 var titleColor = this._map.getParam('marker_title_color'); 251 252 if (titleColor && titleColor != '') { 253 titleDiv.css({ 254 color: titleColor, 255 });
256 } 257 return titleDiv; 258}; 259umsBaseMarker.prototype._setTitleSize = function (titleDiv) { 260 var titleSize = this._map.getParam('marker_title_size'), 261 titleSizeUnits = this._map.getParam('marker_title_size_units'); 262 263 if (titleSize && titleSizeUnits && titleSize != '') { 264 titleDiv.css({ 265 'font-size': titleSize + titleSizeUnits, 266 'line-height': +titleSize + 5 + titleSizeUnits, 267 }); 268 } 269 return titleDiv; 270}; 271umsBaseMarker.prototype._setDescSize = function (descDiv) { 272 var descSize = this._map.getParam('marker_desc_size'), 273 descSizeUnits = this._map.getParam('marker_desc_size_units'); 274 275 if (descSize && descSizeUnits && descSize != '') { 276 descDiv.css({ 277 'font-size': descSize + descSizeUnits, 278 'line-height': parseInt(descSize) + 5 + descSizeUnits, 279 }); 280 } 281 return descDiv; 282}; 283umsBaseMarker.prototype._updateInfoWndContent = function () { 284 this._methodRedefineNotice('umsBaseMarker.prototype._updateInfoWndContent'); 285}; 286/** 287 * Just mark it as closed 288 */ 289umsBaseMarker.prototype._setInfoWndClosed = function () { 290 this._infoWndOpened = false; 291 jQuery(document).trigger('umsAfterHideInfoWnd', this); 292}; 293umsBaseMarker.prototype._setInfoWndContent = function (withoutShowTrigger) { 294 this._methodRedefineNotice('umsBaseMarker.prototype._setInfoWndContent'); 295}; 296umsBaseMarker.prototype.removeFromMap = function () { 297 this._methodRedefineNotice('umsBaseMarker.prototype.removeFromMap'); 298}; 299umsBaseMarker.prototype.setMarkerParams = function (params) { 300 this._markerParams = params; 301 return this; 302}; 303umsBaseMarker.prototype.setMarkerParam = function (key, value) { 304 this._markerParams[key] = value; 305 return this; 306}; 307umsBaseMarker.prototype.getMarkerParam = function (key) { 308 return this._markerParams[key]; 309}; 310umsBaseMarker.prototype.setMap = function (map) { 311 this._methodRedefineNotice('umsBaseMarker.prototype.setMap'); 312}; 313umsBaseMarker.prototype.getMap = function () { 314 return this._map; 315}; 316umsBaseMarker.prototype.setVisible = function (state) { 317 this.getRawMarkerInstance().setVisible(state); 318}; 319umsBaseMarker.prototype.getVisible = function (state) { 320 this.getRawMarkerInstance().getVisible(state); 321}; 322/*umsBaseMarker.prototype.removeFromMap = function() { 323 this._methodRedefineNotice('umsBaseMarker.prototype.removeFromMap'); 324};*/ 325umsBaseMarker.prototype._methodRedefineNotice = function (methodName) { 326 console.log('[' + methodName + '] should be re-defined!'); 327}; 328/*umsBaseMarker.prototype.refreshInfoWnd = function() { 329 this._methodRedefineNotice('umsBaseMarker.prototype.setMap'); 330};*/ 331 332// Common functions 333function _umsPrepareMarkersList(markers, params) { 334 params = params || {}; 335 if (markers) { 336 for (var i = 0; i < markers.length; i++) { 337 markers[i].coord_x = parseFloat(markers[i].coord_x); 338 markers[i].coord_y = parseFloat(markers[i].coord_y); 339 markers[i].icon = markers[i].icon_data.path; 340 if (params.dragend) { 341 markers[i].draggable = true; 342 markers[i].dragend = params.dragend; 343 } 344 } 345 } 346 return markers; 347} 348 349/*var umsMarkerLoader = { 350 init: function(map, markerParams) { 351 return new window['ums'+ toeStrFirstUp(UMS_DATA.engine)+ 'Marker'](map, markerParams); 352 } 353};*/
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.