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