if(typeof UMS_DATA=='undefined') var UMS_DATA={};
if(isNumber(UMS_DATA.animationSpeed)) UMS_DATA.animationSpeed=parseInt(UMS_DATA.animationSpeed);
else if(jQuery.inArray(UMS_DATA.animationSpeed, ['fast', 'slow'])==-1) UMS_DATA.animationSpeed='fast';
UMS_DATA.showSubscreenOnCenter=parseInt(UMS_DATA.showSubscreenOnCenter);
var sdLoaderImgUms='<img src="' + UMS_DATA.loader + '" />';
var g_umsAnimationSpeed=300;
jQuery.fn.showLoaderUms=function (){
return jQuery(this).html(sdLoaderImgUms);
};
jQuery.fn.appendLoaderUms=function (){
jQuery(this).append(sdLoaderImgUms);
};
jQuery.sendFormUms=function (params){
return jQuery('<br />').sendFormUms(params);
};
jQuery.fn.sendFormUms=function (params){
var form=null;
if(!params) params={ fid: false, msgElID: false, onSuccess: false };
if(params.fid) form=jQuery('#' + fid);
else form=jQuery(this);
var sentFromForm=jQuery(form).tagName()=='FORM';
var data=new Array();
if(params.data) data=params.data;
else if(sentFromForm) data=jQuery(form).serialize();
if(params.appendData){
var dataIsString=typeof data=='string';
var addStrData=[];
for (var i in params.appendData){
if(dataIsString){
if(toeInArray(typeof (params.appendData[i], ['object', 'array']))){
for (var j in params.appendData[i]){
addStrData.push(i + '[' + j + ']' + '=' + params.appendData[i][j]);
}}else{
addStrData.push(i + '=' + params.appendData[i]);
}} else data[i]=params.appendData[i];
}
if(dataIsString) data +='&' + addStrData.join('&');
}
var msgEl=null;
if(params.msgElID){
if(params.msgElID=='noMessages') msgEl=false;
else if(typeof params.msgElID=='object') msgEl=params.msgElID;
else msgEl=jQuery('#' + params.msgElID);
}
if(typeof params.inputsWraper=='string'){
form=jQuery('#' + params.inputsWraper);
sentFromForm=true;
}
if(sentFromForm&&form){
jQuery(form).find('*').removeClass('umsInputError');
}
if(msgEl&&!params.btn){
jQuery(msgEl).removeClass('umsSuccessMsg').removeClass('umsErrorMsg').showLoaderUms();
}
if(params.btn){
jQuery(params.btn).attr('disabled', 'disabled');
params.btnIconElement=jQuery(params.btn).find('.fa').length ? jQuery(params.btn).find('.fa'):jQuery(params.btn);
if(jQuery(params.btn).find('.fa').length){
params.btnIconElement.data('prev-class', params.btnIconElement.attr('class')).attr('class', 'fa fa-spinner fa-spin');
}}
var url='';
if(typeof params.url!='undefined') url=params.url;
else if(typeof ajaxurl=='undefined') url=UMS_DATA.ajaxurl;
else url=ajaxurl;
jQuery('.umsErrorForField').hide(UMS_DATA.animationSpeed);
var dataType=params.dataType ? params.dataType:'json';
if(typeof data=='string'){
data +='&pl=' + UMS_DATA.UMS_CODE;
data +='&reqType=ajax';
}else{
data['pl']=UMS_DATA.UMS_CODE;
data['reqType']='ajax';
}
jQuery.ajax({
url: url,
data: data,
type: 'POST',
dataType: dataType,
success: function (res){
toeProcessAjaxResponseUms(res, msgEl, form, sentFromForm, params);
if(params.clearMsg){
setTimeout(
function (){
if(msgEl) jQuery(msgEl).animateClear();
},
typeof params.clearMsg=='boolean' ? 5000:params.clearMsg
);
}},
});
};
jQuery.fn.animateClear=function (){
var newContent=jQuery('<span>' + jQuery(this).html() + '</span>');
jQuery(this).html(newContent);
jQuery(newContent).hide(UMS_DATA.animationSpeed, function (){
jQuery(newContent).remove();
});
};
jQuery.fn.animateRemoveUms=function (animationSpeed, onSuccess){
animationSpeed=animationSpeed==undefined ? UMS_DATA.animationSpeed:animationSpeed;
jQuery(this).hide(animationSpeed, function (){
jQuery(this).remove();
if(typeof onSuccess==='function') onSuccess();
});
};
function toeProcessAjaxResponseUms(res, msgEl, form, sentFromForm, params){
if(typeof params=='undefined') params={};
if(typeof msgEl=='string') msgEl=jQuery('#' + msgEl);
if(msgEl) jQuery(msgEl).html('');
if(params.btn){
jQuery(params.btn).removeAttr('disabled');
if(params.btnIconElement){
params.btnIconElement.attr('class', params.btnIconElement.data('prev-class'));
}}
if(typeof res=='object'){
if(res.error){
if(msgEl){
jQuery(msgEl).removeClass('umsSuccessMsg').addClass('umsErrorMsg');
}
var errorsArr=[];
for (var name in res.errors){
if(sentFromForm){
var inputError=jQuery(form).find('[name*="' + name + '"]');
inputError.addClass('umsInputError');
if(inputError.attr('placeholder')){
}
if(!inputError.data('keyup-error-remove-binded')){
inputError
.keydown(function (){
jQuery(this).removeClass('umsInputError');
})
.data('keyup-error-remove-binded', 1);
}}
if(jQuery('.umsErrorForField.toe_' + nameToClassId(name) + '').exists())
jQuery('.umsErrorForField.toe_' + nameToClassId(name) + '')
.show()
.html(res.errors[name]);
else if(msgEl) jQuery(msgEl).append(res.errors[name]).append('<br />');
else errorsArr.push(res.errors[name]);
}
if(errorsArr.length&&params.btn){
jQuery('<div />').html(errorsArr.join('<br />')).appendTo('body').dialog({
modal: true,
width: '500px',
});
}}else if(res.messages.length){
if(msgEl){
jQuery(msgEl).removeClass('umsErrorMsg').addClass('umsSuccessMsg');
for (var i=0; i < res.messages.length; i++){
jQuery(msgEl).append(res.messages[i]).append('<br />');
}}
}}
if(params.onSuccess&&typeof params.onSuccess=='function'){
params.onSuccess(res);
}}
function getDialogElementUms(){
return jQuery('<div/>').appendTo(jQuery('body'));
}
function toeOptionUms(key){
if(UMS_DATA.options&&UMS_DATA.options[key]&&UMS_DATA.options[key].value) return UMS_DATA.options[key].value;
return false;
}
function toeLangUms(key){
if(UMS_DATA.siteLang&&UMS_DATA.siteLang[key]) return UMS_DATA.siteLang[key];
return key;
}
function toePagesUms(key){
if(typeof UMS_DATA!='undefined'&&UMS_DATA[key]) return UMS_DATA[key];
return false;
}
function toeOptTimeoutHideDescriptionUms(){
jQuery('#umsOptDescription').removeAttr('toeFixTip');
setTimeout(function (){
if(!jQuery('#umsOptDescription').attr('toeFixTip')) toeOptHideDescriptionUms();
}, 500);
}
function toeOptShowDescriptionUms(description, x, y, moveToLeft){
if(typeof description!='undefined'&&description!=''){
if(!jQuery('#umsOptDescription').length){
jQuery('body').append('<div id="umsOptDescription"></div>');
}
if(moveToLeft) jQuery('#umsOptDescription').css('right', jQuery(window).width() - (x - 10));
else jQuery('#umsOptDescription').css('left', x + 10);
jQuery('#umsOptDescription').css('top', y);
jQuery('#umsOptDescription').show(200);
jQuery('#umsOptDescription').html(description);
}}
function toeOptHideDescriptionUms(){
jQuery('#umsOptDescription').removeAttr('toeFixTip');
jQuery('#umsOptDescription').hide(200);
}
function toeInArrayUms(needle, haystack){
if(haystack){
for (var i in haystack){
if(haystack[i]==needle) return true;
}}
return false;
}
function toeShowDialogCustomized(element, options){
options=jQuery.extend({
resizable: false,
width: 500,
height: 300,
closeOnEscape: true,
open: function (event, ui){
jQuery('.ui-dialog-titlebar').css({
'background-color': '#222222',
'background-image': 'none',
border: 'none',
margin: '0',
padding: '0',
'border-radius': '0',
color: '#CFCFCF',
height: '27px',
});
jQuery('.ui-dialog-titlebar-close')
.css({
background: 'url("' + UMS_DATA.cssPath + 'img/tb-close.png") no-repeat scroll 0 0 transparent',
border: '0',
width: '15px',
height: '15px',
padding: '0',
'border-radius': '0',
margin: '7px 7px 0',
})
.html('');
jQuery('.ui-dialog').css({
'border-radius': '3px',
'background-color': '#FFFFFF',
'background-image': 'none',
padding: '1px',
'z-index': '300000',
position: 'fixed',
top: '60px',
});
jQuery('.ui-dialog-buttonpane').css({
'background-color': '#FFFFFF',
});
jQuery('.ui-dialog-title').css({
color: '#CFCFCF',
font: '12px sans-serif',
padding: '6px 10px 0',
});
if(options.openCallback&&typeof options.openCallback=='function'){
options.openCallback(event, ui);
}
jQuery('.ui-widget-overlay').css({
'z-index': jQuery(event.target).parents('.ui-dialog:first').css('z-index') - 1,
'background-image': 'none',
});
if(options.modal&&options.closeOnBg){
jQuery('.ui-widget-overlay')
.unbind('click')
.bind('click', function (){
jQuery(element).dialog('close');
});
}},
},
options
);
return jQuery(element).dialog(options);
}
function toeSliderMove(event, ui){
var id=jQuery(event.target).attr('id');
var value=typeof ui.value==='undefined' ? jQuery('#toeSliderInput_' + id).val():ui.value;
var units=value==1 ? jQuery('#toeSliderDisplay_' + id).data('units'):jQuery('#toeSliderDisplay_' + id).data('units-plur');
jQuery('#toeSliderDisplay_' + id).html(value + ' ' + units);
jQuery('#toeSliderInput_' + id)
.val(value)
.change();
}
function setBrowserUrl(url){
if(typeof history.pushState!='undefined'){
var obj={ Title: document.title, Url: url };
history.pushState(obj, obj.Title, obj.Url);
}}
function createAjaxLinkUms(param){
return UMS_DATA.ajaxurl + '?' + paramUms(param);
}
function paramUms(param){
var param=jQuery.extend({}, param);
param['pl']=UMS_DATA.UMS_CODE;
return jQuery.param(param);
}
function umsGetTxtEditorVal(id){
var elem=jQuery('#' + id),
content=typeof tinyMCE!=='undefined'&&tinyMCE.get(id)&&!elem.is(':visible') ? tinyMCE.get(id).getContent():elem.val();
return content;
}
function umsSetTxtEditorVal(id, content){
var elem=jQuery('#' + id);
if(typeof tinyMCE!=='undefined'&&tinyMCE&&tinyMCE.get(id)&&!elem.is(':visible')){
tinyMCE.get(id).setContent(content);
}else{
elem.val(content);
}};
function umsBaseMap(elementId, mapData, engine, additionalParams){
mapData=mapData ? mapData:{};
additionalParams=additionalParams ? additionalParams:{};
var defaults={};
this._engine=engine;
this._fullEngine=additionalParams.fullEngine ? additionalParams.fullEngine:this._engine;
this._$markerInfoWndStyle=null;
this._elementId=elementId;
this._clearElementId=str_replace(this._elementId, '#', '');
this._element=typeof elementId==='string' ? jQuery(elementId)[0]:elementId;
this._mapParams=jQuery.extend({}, defaults, mapData.params);
this._mapObj=null;
this._markers=[];
this._shapes=[];
this._heatmap=[];
this._kmlLayers=[];
this._clasterer=null;
this._clastererEnabled=false;
this._clastererMarkersGroupsStyles=[];
this._initComplete=false;
this.init();
}
umsBaseMap.prototype.getEngine=function (){
return this._engine;
};
umsBaseMap.prototype.init=function (){
this._beforeInit();
this._createMapObj();
this._refreshMarkerInfoWndStyle();
this._afterInit();
this._initComplete=true;
};
umsBaseMap.prototype._createMapObj=function (){
};
umsBaseMap.prototype._beforeInit=function (){
jQuery(document).trigger('umsBeforeMapInit', this);
};
umsBaseMap.prototype.getParams=function (){
return this._mapParams;
};
umsBaseMap.prototype.getParam=function (key){
return this._mapParams[key];
};
umsBaseMap.prototype.setParam=function (key, value){
this._mapParams[key]=value;
return this;
};
umsBaseMap.prototype.resizeMapByHeight=function (){
if(!UMS_DATA.isAdmin&&parseInt(this.getParam('adapt_map_to_screen_height'))&&this.getRawMapInstance().map_display_mode!='popup'){
var self=this;
function resizeHeight(){
var viewId=self.getParam('view_id'),
mapContainer=jQuery('#umsMapDetailsContainer_' + viewId),
mapContainerOffset=mapContainer.length ? mapContainer.offset():false,
windowHeight=jQuery(window).height();
if(mapContainerOffset){
jQuery('#umsMapDetailsContainer_' + viewId + ', #' + self.getParam('view_html_id')).each(function (){
var height=mapContainerOffset.top < windowHeight ? windowHeight - mapContainerOffset.top:windowHeight;
jQuery(this).height(height);
});
}}
resizeHeight();
jQuery(window).bind('resize', resizeHeight);
jQuery(window).bind('orientationchange', resizeHeight);
}};
umsBaseMap.prototype._afterInit=function (){
if(typeof this._mapParams.marker_clasterer!=='undefined'&&this._mapParams.marker_clasterer){
this.enableClasterization(this._mapParams.marker_clasterer);
}
this.resizeMapByHeight();
jQuery(document).trigger('umsAfterMapInit', this);
};
umsBaseMap.prototype.addMarker=function (params){
var newMarker=this._createMarkerObj(params);
this._markers.push(newMarker);
return newMarker;
};
umsBaseMap.prototype._createMarkerObj=function (params){
return umsMapLoader.initMarker(this, params);
};
umsBaseMap.prototype.getMarkerById=function (id){
if(this._markers&&this._markers.length){
id=parseInt(id);
for (var i in this._markers){
if(this._markers[i].getId&&this._markers[i].getId()===id) return this._markers[i];
}}
return false;
};
umsBaseMap.prototype.removeMarker=function (id){
var marker=this.getMarkerById(id);
if(marker){
marker.removeFromMap();
}};
umsBaseMap.prototype.getAllMarkers=function (){
return this._markers;
};
umsBaseMap.prototype.addEventListener=function (event, callback){
this._methodRedefineNotice('umsBaseMap.prototype.addEventListener');
};
umsBaseMap.prototype.setCenter=function (lat, lng){
this._methodRedefineNotice('umsBaseMap.prototype.setCenter');
};
umsBaseMap.prototype.getCenter=function (){
this._methodRedefineNotice('umsBaseMap.prototype.getCenter');
};
umsBaseMap.prototype.setZoom=function (zoomLevel){
this._methodRedefineNotice('umsBaseMap.prototype.setZoom');
};
umsBaseMap.prototype.getZoom=function (){
this._methodRedefineNotice('umsBaseMap.prototype.getZoom');
};
umsBaseMap.prototype.setMapType=function (mapType){
this._methodRedefineNotice('umsBaseMap.prototype.setMapType');
};
umsBaseMap.prototype.markersRefresh=function (){
var clasterer=this.getClasterer();
if(this._clastererEnabled&&clasterer){
this._refreshCluster();
}
jQuery(document).trigger('umsAfterMarkersRefresh', this);
};
umsBaseMap.prototype._refreshCluster=function (){
this._methodRedefineNotice('umsBaseMap.prototype._refreshCluster');
};
umsBaseMap.prototype.getAllRawMarkers=function (){
var res=[];
if(this._markers&&this._markers.length){
for (var i=0; i < this._markers.length; i++){
res.push(this._markers[i].getRawMarkerInstance());
}}
return res;
};
umsBaseMap.prototype._methodRedefineNotice=function (methodName){
console.log('[' + methodName + '] should be re-defined!');
};
umsBaseMap.prototype.clearMarkers=function (){
if(this._markers&&this._markers.length){
for (var i=0; i < this._markers.length; i++){
this._markers[i].removeFromMap();
}
this._markers=[];
}};
umsBaseMap.prototype.clearMarkersByParam=function (param){
if(this._markers&&this._markers.length){
for (var i=0; i < this._markers.length; i++){
if(this._markers[i].getMarkerParam(param)){
this._markers[i].removeFromMap();
this._markers.splice(i, 1);
this.clearMarkersByParam(param);
break;
}}
}};
umsBaseMap.prototype._runAfterInitComplete=function (clb){
};
umsBaseMap.prototype.setNavigationBarMode=function (mode){
this._methodRedefineNotice('umsBaseMap.prototype.setNavigationBarMode');
};
umsBaseMap.prototype.getNavigationBarMode=function (){
this._methodRedefineNotice('umsBaseMap.prototype.getNavigationBarMode');
};
umsBaseMap.prototype.enbZoom=function (mode){
this._methodRedefineNotice('umsBaseMap.prototype.enbZoom');
};
umsBaseMap.prototype.enbDraggable=function (mode){
this._methodRedefineNotice('umsBaseMap.prototype.enbDraggable');
};
umsBaseMap.prototype.enbWheelZoom=function (mode){
this._methodRedefineNotice('umsBaseMap.prototype.enbWheelZoom');
};
umsBaseMap.prototype.geocodeQuery=function (search, clb){
this._methodRedefineNotice('umsBaseMap.prototype.geocodeQuery');
};
umsBaseMap.prototype.getClasterer=function (){
if(this._clasterer){
return this._clasterer;
}
return false;
};
umsBaseMap.prototype.setClasterer=function (clasterer){
this._clasterer=clasterer;
};
umsBaseMap.prototype.geocodeSearchAutocomplete=function ($el, params){
params=params||{};
var mapSelf=this;
$el=typeof $el==='string' ? jQuery($el):$el;
$el.keyup(function (event){
if(toeInArrayUms(event.keyCode, [9, 13, 20, 35, 36, 37, 38, 39, 40])) return;
var searchData=jQuery.trim(jQuery(this).val());
if(searchData&&searchData!=''){
if(typeof params.msgEl==='string'){
params.msgEl=jQuery(params.msgEl);
}
params.msgEl.showLoaderUms();
var self=this;
jQuery(this).autocomplete({
source: function (request, response){
var autocomleateData=typeof params.additionalData!='undefined' ? umsAutocomleateData(params.additionalData, request.term):[];
mapSelf.geocodeQuery(searchData,
function (results){
params.msgEl.html('');
for (var i=0; i < results.length; i++){
autocomleateData.push({
label: results[i].formatted_address,
lat: results[i].lat,
lng: results[i].lng,
});
}
response(autocomleateData);
},
function (event){
if(autocomleateData&&autocomleateData.length > 0){
response(autocomleateData);
}else{
var notFoundMsg=toeLangUms('Nothing was found');
if(jQuery(self).parent().find('.ui-helper-hidden-accessible').length){
jQuery(self).parent().find('.ui-helper-hidden-accessible').html(notFoundMsg);
}else{
params.msgEl.html(notFoundMsg);
}}
}
);
},
select: function (event, ui){
if(params.onSelect){
params.onSelect(ui.item, event, ui);
}
jQuery(self).removeClass('ui-autocomplete-loading');
},
});
jQuery(this).autocomplete('search');
}});
function umsAutocomleateData(data, needle){
var autocomleateData=[];
for (var i=0; i < data.length; i++){
for (var j=0; j < data[i].length; j++){
if(data[i][j]){
var label=data[i][j].label.toString().toLowerCase(),
desc=data[i][j].marker_desc!='undefined' ? data[i][j].marker_desc:'',
term=needle.toLowerCase();
if(label.indexOf(term)!==-1||(desc&&desc.indexOf(term)!==-1)){
autocomleateData.push(data[i][j]);
}}
}}
return autocomleateData;
}};
umsBaseMap.prototype.getRawMapInstance=function (){
return this._mapObj;
};
umsBaseMap.prototype.checkMarkersParams=function (markers, needToShow){
if(markers&&markers.length){
for (var i=0; i < markers.length; i++){
var markerParams=markers[i].getMarkerParam('params'),
showDescription=parseInt(markerParams.show_description);
if(showDescription||needToShow){
markers[i].showInfoWnd(true, showDescription, true);
}}
}};
umsBaseMap.prototype.setMarkerInfoWndWidthUnits=function (type){
this.setParam('marker_infownd_width_units', type);
this._refreshMarkerInfoWndStyle();
};
umsBaseMap.prototype.setMarkerInfoWndWidth=function (width){
this.setParam('marker_infownd_width', width);
this._refreshMarkerInfoWndStyle();
};
umsBaseMap.prototype.setMarkerInfoWndHeightUnits=function (type){
this.setParam('marker_infownd_height_units', type);
this._refreshMarkerInfoWndStyle();
};
umsBaseMap.prototype.setMarkerInfoWndHeight=function (height){
this.setParam('marker_infownd_height', height);
this._refreshMarkerInfoWndStyle();
};
umsBaseMap.prototype.setMarkerInfoWndTitleColor=function (color){
this.setParam('marker_title_color', color);
this._refreshMarkerInfoWndStyle();
};
umsBaseMap.prototype.setMarkerInfoWndBgColor=function (color){
this.setParam('marker_infownd_bg_color', color);
this._refreshMarkerInfoWndStyle();
};
umsBaseMap.prototype.setMarkerInfoWndTitleSize=function (size){
this.setParam('marker_title_size', size);
this._refreshMarkerInfoWndStyle();
};
umsBaseMap.prototype.setMarkerInfoWndDescSize=function (size){
this.setParam('marker_desc_size', size);
this._refreshMarkerInfoWndStyle();
};
umsBaseMap.prototype._refreshMarkerInfoWndStyle=function (){
var styleHtml=this._generateMarkerInfoWndStyle();
if(!styleHtml) return;
if(!this._$markerInfoWndStyle){
this._$markerInfoWndStyle=jQuery('<style id="umsMarkerInfoWndStyle_' + this._clearElementId + '">').appendTo('body');
}
this._$markerInfoWndStyle.html(styleHtml);
};
umsBaseMap.prototype._generateMarkerInfoWndStyle=function (){
return false;
};
umsBaseMap.prototype._getCreateCoords=function (){
return this._mapParams.map_center&&this._mapParams.map_center.coord_x&&this._mapParams.map_center.coord_x!==''&&this._mapParams.map_center.coord_y&&this._mapParams.map_center.coord_y!=='' ? this._mapParams.map_center:{ coord_x: 51.50632, coord_y: -0.12714 };};
umsBaseMap.prototype.enableClasterization=function (clasterType, needTrigger){
this._clastererEnabled=true;
};
umsBaseMap.prototype.disableClasterization=function (){
this._clastererEnabled=false;
};
umsBaseMap.prototype.setClusterSize=function (size){
this._methodRedefineNotice('umsBaseMap.prototype.geocodeQuery');
};
umsBaseMap.prototype.getViewId=function (){
return this._mapParams.view_id;
};
umsBaseMap.prototype.getViewHtmlId=function (){
return this._mapParams.view_html_id;
};
umsBaseMap.prototype.getId=function (){
return this._mapParams.id;
};
umsBaseMap.prototype.closeAllInfoWnd=function (){
if(this._markers&&this._markers.length){
for (var i=0; i < this._markers.length; i++){
this._markers[i].hideInfoWnd();
}}
};
umsBaseMap.prototype.clearShapes=function (){
if(this._shapes&&this._shapes.length){
for (var i=0; i < this._shapes.length; i++){
this._shapes[i].setMap(null);
}
this._shapes=[];
}};
umsBaseMap.prototype.addShape=function (params){
var newShape=umsShapeLoader.initShape(this, params);
this._shapes.push(newShape);
return newShape;
};
umsBaseMap.prototype.addHeatmap=function (params){
this._heatmap.push(heatmap);
return heatmap;
};
umsBaseMap.prototype.getShapeById=function (id){
if(this._shapes&&this._shapes.length){
for (var i in this._shapes){
if(this._shapes[i].getId()==id) return this._shapes[i];
}}
return false;
};
umsBaseMap.prototype.getHeatmap=function (){
if(this._heatmap&&this._heatmap.length){
return this._heatmap[0];
}
return false;
};
umsBaseMap.prototype.removeShape=function (id){
var shape=this.getShapeById(id);
if(shape){
shape.removeFromMap();
}};
umsBaseMap.prototype.getAllShapes=function (){
return this._shapes;
};
umsBaseMap.prototype.addKmlLayer=function (layer){
this._kmlLayers.push(layer);
};
umsBaseMap.prototype.removeKmlLayerByUrl=function (url){
if(this._kmlLayers.length){
for (var i=0; i < this._kmlLayers.length; i++){
if(this._kmlLayers[i].getUrl()==url){
this._kmlLayers[i].removeFromMap();
this._kmlLayers.splice(i, 1);
break;
}}
}};
umsBaseMap.prototype._setMinZoomLevel=function (){
var curZoom=this.getZoom();
var minZoom=parseInt(this._mapParams.zoom_min) ? parseInt(this._mapParams.zoom_min):null;
if(curZoom < minZoom) this.setZoom(minZoom);
};
umsBaseMap.prototype._setMaxZoomLevel=function (){
var maxZoom=parseInt(this._mapParams.zoom_max) ? parseInt(this._mapParams.zoom_max):null;
if(this.getRawMapInstance().zoom > maxZoom) this.setZoom(maxZoom);
};
/*umsBaseMap.prototype._fixZoomLevel=function(){
var eventHandle=this._getEventListenerHandle('zoom_changed', 'zoomChanged');
if(!eventHandle){
eventHandle=google.maps.event.addListener(this.getRawMapInstance(), 'zoom_changed', jQuery.proxy(function(){
var minZoom=parseInt(this.getParam('zoom_min'))
,	maxZoom=parseInt(this.getParam('zoom_max'));
if(this.getZoom() < minZoom){
this.setZoom(minZoom);
if(GMP_DATA.isAdmin&&this._getEventListenerHandle('idle', 'enableClasterization'))
google.maps.event.trigger(this.getRawMapInstance(), 'idle');
}
if(this.getZoom() > maxZoom){
this.setZoom(maxZoom);
if(GMP_DATA.isAdmin&&this._getEventListenerHandle('idle', 'enableClasterization'))
google.maps.event.trigger(this.getRawMapInstance(), 'idle');
}}, this));
this._addEventListenerHandle('zoom_changed', 'zoomChanged', eventHandle);
}};*/
var umsMapLoader={
initMap: function (elementId, mapData, additionalParams){
var engine=umsGetMapsEngine(mapData);
additionalParams=additionalParams ? additionalParams:{};
additionalParams.fullEngine=umsGetMapsFullEngine(mapData);
return new window['ums' + toeStrFirstUp(engine) + 'Map'](elementId, mapData, engine, additionalParams);
},
initMarker: function (map, markerParams){
return new window['ums' + toeStrFirstUp(map.getEngine()) + 'Marker'](map, markerParams);
},
};
var g_umsMapLoadObserver={
_loaded: {},
setLoaded: function (engine){
this._loaded[engine]=true;
},
isLoaded: function (engine){
return this._loaded[engine];
},
trigger: function (engine, clb){
if(this.isLoaded(engine)){
clb();
}else{
var self=this;
setTimeout(function (){
self.trigger(engine, clb);
}, 500);
}},
};
function umsGetMapsEngine(map){
var fullEngine=umsGetMapsFullEngine(map);
if(fullEngine.indexOf('l-')===0){
return 'leaflet';
}
return fullEngine;
}
function umsGetMapsFullEngine(map){
if(map&&typeof map.getEngine==='function'){
return map.getEngine();
}
if(map&&map.engine&&map.engine!==''){
return map.engine;
}
return UMS_DATA.engine;
}
function gmpAutocomleateData(data, needle){
var autocomleateData=[];
for (var i=0; i < data.length; i++){
for (var j=0; j < data[i].length; j++){
if(data[i][j]){
var label=data[i][j].label.toString().toLowerCase(),
desc=data[i][j].marker_desc!='undefined' ? data[i][j].marker_desc:'',
term=needle.toLowerCase();
if(label.indexOf(term)!==-1||(desc&&desc.indexOf(term)!==-1)){
autocomleateData.push(data[i][j]);
}}
}}
return autocomleateData;
};
function umsBaseMarker(map, params){
this._map=map;
this._markerObj=null;
var defaults={
};
this._markerParams=jQuery.extend({}, defaults, params);
this._markerParams.map=this._map.getRawMapInstance();
this._infoWindow=null;
this._infoWndOpened=false;
this._infoWndWasInited=false;
this._infoWndDirectionsBtn=false;
this._infoWndPrintBtn=false;
this._mapDragScroll={
scrollwheel: null,
};
this._ignoreBaseInfoWndBind=false;
this.init();
}
umsBaseMarker.prototype.infoWndOpened=function (){
return this._infoWndOpened;
};
umsBaseMarker.prototype._createMarkerObj=function (){
this._methodRedefineNotice('umsBaseMarker.prototype._createMarkerObj');
};
umsBaseMarker.prototype.init=function (){
this._markerObj=this._createMarkerObj();
var openInfoWndEvent='click',
closeInfoWndEvent='',
openLinkEvent='click';
/*var markerParamsForCreate=this._markerParams
,	openInfoWndEvent='click'
,	closeInfoWndEvent=''
,	openLinkEvent='click';
if(parseInt(this._map._mapParams.hide_marker_tooltip)){
this._markerParams.marker_title=this._markerParams.title;
delete markerParamsForCreate.title;
}
this._markerObj=new google.maps.Marker(markerParamsForCreate);
this._markerObj.addListener('domready', jQuery.proxy(function(){
changeInfoWndBgColor(this._map);
}, this));*/
if(this._markerParams.dragend){
this.addEventListener('dragend', jQuery.proxy(this._markerParams.dragend, this));
}
if(this._markerParams.click){
this.addEventListener('click', jQuery.proxy(this._markerParams.click, this));
}
if(!navigator.userAgent.match(/iPad|iPhone|iPod|Android|BlackBerry|webOS/i)){
if(parseInt(this._map._mapParams.marker_hover)){
this.addEventListener('mouseover',
jQuery.proxy(function (){
if(typeof this._markerObj.opacity=='undefined'||this._markerObj.opacity==1){
this.showInfoWnd();
jQuery(document).trigger('umsAfterMarkerClick', this);
}}, this)
);
}}
if(this._markerParams.params&&!(window.ontouchstart===null||navigator.msMaxTouchPoints)){
if(parseInt(this._markerParams.params.description_mouse_hover)){
openInfoWndEvent='mouseover';
if(parseInt(this._markerParams.params.description_mouse_leave)){
closeInfoWndEvent='mouseout';
}}
}
if(!this._ignoreBaseInfoWndBind){
this.addEventListener(openInfoWndEvent,
jQuery.proxy(function (){
if(this._markerParams.params&&!parseInt(this._markerParams.params.description_mouse_hover)&&parseInt(this._markerParams.params.marker_link)){
return;
}else{
this.showInfoWnd();
}
jQuery(document).trigger('umsAfterMarkerClick', this);
}, this)
);
}
if(closeInfoWndEvent){
/*this.addEventListener(closeInfoWndEvent, jQuery.proxy(function (){
var self=this
,	infoWndDiv=jQuery('.gm-style-iw').parent()
,	timeout=300;
infoWndDiv.on('mouseover', function (){
infoWndDiv.addClass('hovering');
});
infoWndDiv.on('mouseleave', function (){
setTimeout(function(){
self.hideInfoWnd();
}, timeout);
});
setTimeout(function(){
if(!infoWndDiv.hasClass('hovering')){
self.hideInfoWnd();
}}, timeout);
}, this));*/
}
if(this._markerParams.params&&parseInt(this._markerParams.params.marker_link)){
this.addEventListener(openLinkEvent,
jQuery.proxy(function (){
var url_string=window.location.href,
url=new URL(url_string),
tab=url.searchParams.get('tab');
if(tab!=='maps_edit'){
var isLink=/http/gi,
markerLink = !this._markerParams.params.marker_link_src.match(isLink) ? 'http://' + this._markerParams.params.marker_link_src:this._markerParams.params.marker_link_src;
if(parseInt(this._markerParams.params.marker_link_new_wnd)){
window.open(markerLink, '_blank');
}else{
location.href=markerLink;
}}
}, this)
);
}};
umsBaseMarker.prototype.addEventListener=function (event, callback){
this._methodRedefineNotice('umsBaseMarker.prototype.addEventListener');
};
umsBaseMarker.prototype.showInfoWnd=function (forceUpdateInfoWnd, forceShow, withOpenPopup){
if(!this._infoWndWasInited||forceUpdateInfoWnd){
this._updateInfoWndContent(true);
this._infoWndWasInited=true;
}
if(this._infoWindow&&!this._infoWndOpened){
var allMapMArkers=this._map.getAllMarkers();
if(allMapMArkers&&allMapMArkers.length > 1&&!forceShow){
for (var i=0; i < allMapMArkers.length; i++){
allMapMArkers[i].hideInfoWnd();
}}
this._openInfoWnd(withOpenPopup);
}
this._infoWndOpened=true;
if(!navigator.userAgent.match(/iPad|iPhone|iPod|Android|BlackBerry|webOS/i)){
if(parseInt(this._map._mapParams.marker_hover)){
this.directOpenInfoWnd();
}}
};
umsBaseMarker.prototype._openInfoWnd=function (withOpenPopup){
this._methodRedefineNotice('umsBaseMarker.prototype._openInfoWnd');
};
umsBaseMarker.prototype.directOpenInfoWnd=function (){
this._methodRedefineNotice('umsBaseMarker.prototype.directOpenInfoWnd');
};
umsBaseMarker.prototype._closeInfoWnd=function (){
this._methodRedefineNotice('umsBaseMarker.prototype._closeInfoWnd');
};
umsBaseMarker.prototype.hideInfoWnd=function (){
if(this._infoWindow&&this._infoWndOpened){
this._closeInfoWnd();
this._infoWndOpened=false;
}};
umsBaseMarker.prototype.getRawMarkerInstance=function (){
return this._markerObj;
};
umsBaseMarker.prototype.getRawMarkerParams=function (){
return this._markerParams;
};
umsBaseMarker.prototype.getIcon=function (){
this._methodRedefineNotice('umsBaseMarker.prototype.getIcon');
};
umsBaseMarker.prototype.setIcon=function (iconPath){
this._methodRedefineNotice('umsBaseMarker.prototype.setIcon');
};
umsBaseMarker.prototype.setIconSize=function (width, height){
if(typeof this._markerParams.icon_data==='undefined'){
this._markerParams.icon_data={};}
this._markerParams.icon_data.width=width;
this._markerParams.icon_data.height=height;
};
umsBaseMarker.prototype.setTitle=function (title, noRefresh){
this._markerParams.title=title;
if(!noRefresh) this._updateInfoWndContent();
};
umsBaseMarker.prototype.getTitle=function (){
return this._markerParams.title;
};
umsBaseMarker.prototype.getPosition=function (){
this._methodRedefineNotice('umsBaseMarker.prototype.getPosition');
};
umsBaseMarker.prototype.setPosition=function (lat, lng){
this._methodRedefineNotice('umsBaseMarker.prototype.setPosition');
};
umsBaseMarker.prototype.lat=function (){
this._methodRedefineNotice('umsBaseMarker.prototype.lat');
};
umsBaseMarker.prototype.lng=function (lng){
this._methodRedefineNotice('umsBaseMarker.prototype.lng');
};
umsBaseMarker.prototype.setId=function (id){
this._markerParams.id=id;
};
umsBaseMarker.prototype.getId=function (){
return parseInt(this._markerParams.id);
};
umsBaseMarker.prototype.setDescription=function (description, noRefresh){
this._markerParams.description=description;
if(!noRefresh) this._updateInfoWndContent();
if(this._markerParams.params&&parseInt(this._markerParams.params.show_description)){
this.showInfoWnd(false, true);
}};
umsBaseMarker.prototype.getDescription=function (){
return this._markerParams.description;
};
umsBaseMarker.prototype._setTitleColor=function (titleDiv){
var titleColor=this._map.getParam('marker_title_color');
if(titleColor&&titleColor!=''){
titleDiv.css({
color: titleColor,
});
}
return titleDiv;
};
umsBaseMarker.prototype._setTitleSize=function (titleDiv){
var titleSize=this._map.getParam('marker_title_size'),
titleSizeUnits=this._map.getParam('marker_title_size_units');
if(titleSize&&titleSizeUnits&&titleSize!=''){
titleDiv.css({
'font-size': titleSize + titleSizeUnits,
'line-height': +titleSize + 5 + titleSizeUnits,
});
}
return titleDiv;
};
umsBaseMarker.prototype._setDescSize=function (descDiv){
var descSize=this._map.getParam('marker_desc_size'),
descSizeUnits=this._map.getParam('marker_desc_size_units');
if(descSize&&descSizeUnits&&descSize!=''){
descDiv.css({
'font-size': descSize + descSizeUnits,
'line-height': parseInt(descSize) + 5 + descSizeUnits,
});
}
return descDiv;
};
umsBaseMarker.prototype._updateInfoWndContent=function (){
this._methodRedefineNotice('umsBaseMarker.prototype._updateInfoWndContent');
};
umsBaseMarker.prototype._setInfoWndClosed=function (){
this._infoWndOpened=false;
jQuery(document).trigger('umsAfterHideInfoWnd', this);
};
umsBaseMarker.prototype._setInfoWndContent=function (withoutShowTrigger){
this._methodRedefineNotice('umsBaseMarker.prototype._setInfoWndContent');
};
umsBaseMarker.prototype.removeFromMap=function (){
this._methodRedefineNotice('umsBaseMarker.prototype.removeFromMap');
};
umsBaseMarker.prototype.setMarkerParams=function (params){
this._markerParams=params;
return this;
};
umsBaseMarker.prototype.setMarkerParam=function (key, value){
this._markerParams[key]=value;
return this;
};
umsBaseMarker.prototype.getMarkerParam=function (key){
return this._markerParams[key];
};
umsBaseMarker.prototype.setMap=function (map){
this._methodRedefineNotice('umsBaseMarker.prototype.setMap');
};
umsBaseMarker.prototype.getMap=function (){
return this._map;
};
umsBaseMarker.prototype.setVisible=function (state){
this.getRawMarkerInstance().setVisible(state);
};
umsBaseMarker.prototype.getVisible=function (state){
this.getRawMarkerInstance().getVisible(state);
};
/*umsBaseMarker.prototype.removeFromMap=function(){
this._methodRedefineNotice('umsBaseMarker.prototype.removeFromMap');
};*/
umsBaseMarker.prototype._methodRedefineNotice=function (methodName){
console.log('[' + methodName + '] should be re-defined!');
};
/*umsBaseMarker.prototype.refreshInfoWnd=function(){
this._methodRedefineNotice('umsBaseMarker.prototype.setMap');
};*/
function _umsPrepareMarkersList(markers, params){
params=params||{};
if(markers){
for (var i=0; i < markers.length; i++){
markers[i].coord_x=parseFloat(markers[i].coord_x);
markers[i].coord_y=parseFloat(markers[i].coord_y);
markers[i].icon=markers[i].icon_data.path;
if(params.dragend){
markers[i].draggable=true;
markers[i].dragend=params.dragend;
}}
}
return markers;
}
/*var umsMarkerLoader={
init: function(map, markerParams){
return new window['ums'+ toeStrFirstUp(UMS_DATA.engine)+ 'Marker'](map, markerParams);
}};*/;