
var o2=new Object(); o2.Env = { Browser: { IE:     !!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1), IE7:    !!(window.attachEvent && !window.opera && window.XMLHttpRequest), Opera:  navigator.userAgent.indexOf('Opera') > -1, WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') === -1, MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) }, ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, emptyFunction: function() { }, echoFunction: function(x) { return x }
}; o2.ObjectExtend = function(destination, source) { for (var property in source)
destination[property] = source[property]; return destination; }; o2.ObjectToQueryString=function(object) { var tmp = []; for (key in object)
tmp.push(key+'='+encodeURIComponent(String(object[key]))); return tmp.join('&'); }; o2.ObjectMerge=function(destination, source) { var args=Array.prototype.slice.call(arguments); args.shift(); args.shift(); argsList=";" + args.join(";") + ";"; for (var property in source) { if(source[property]==null) { delete destination[property]; continue; }
if(destination[property] instanceof Array && source[property] instanceof Array) { o2.ArrayMerge(destination[property], source[property]); continue; }
if(argsList.indexOf(property)==-1)
destination[property]=source[property]; else
o2.ObjectMerge(destination[property], source[property]); }
}; o2.ElementUpdateString=function(ts, content) { ts.innerHTML = content.replace(new RegExp(o2.Env.ScriptFragment, 'img'), ''); return ts; }; o2.ElementSize=function(ts) { if (!ts.style.display && ts.style.display!='none')
return {width: ts.offsetWidth, height: ts.offsetHeight}; var els = ts.style; var originalVisibility = els.visibility; var originalPosition = els.position; var originalDisplay = els.display; els.visibility = 'hidden'; els.position = 'absolute'; els.display = 'block'; var originalWidth = ts.clientWidth; var originalHeight = ts.clientHeight; els.display = originalDisplay; els.position = originalPosition; els.visibility = originalVisibility; return {width: originalWidth, height: originalHeight}; }; o2.ElementSelect=function(ts, tagName, className) { var result=new Array()
var tags=ts.getElementsByTagName(tagName); if(className=="")
return tags; var len=tags.length; while(len--)
if(tags[len].className && tags[len].className==className)
result.push(tags[len]); return result; }; o2.FunctionBind=function() { var args=Array.prototype.slice.call(arguments); var __method = args.shift(); var object = args.shift(); return function() { var localArgs=new Array(); for(var j=0; j<args.length; j++)
localArgs.push(args[j]); for(var i=0; i<arguments.length; i++)
localArgs.push(arguments[i]); return __method.apply(object, localArgs); }
}; o2.FunctionBindAsEventListener=function() { var args = Array.prototype.slice.call(arguments); var __method=args.shift(); var object = args.shift(); return function(event) { var arts=[event || window.event]; for(var i=0; i<args.length; i++)
arts.push(args[i]); return __method.apply(object, arts); }
}; o2.ArrayCompact=function(ts) { var result=new Array(); for(var i=0, len=ts.length; i<len; i++)
if(ts[i]!=null && typeof(ts[i])!="undefined")
result.push(ts[i]); return result; }
o2.ArrayMerge=function(destination, source) { var belong, dlen; for(var slen=0; slen<source.length; slen++) { belong=false; dlen=destination.length; while(dlen--)
if(destination[dlen]==source[slen])
belong=true; if(!belong)
destination.push(source[slen]); }
return destination; }
o2.ClassCreate=function() { var properties = Array.prototype.slice.call(arguments); var parent = null; if(typeof(properties[0])=='function')
parent = properties.shift(); function klass() { this.initialize.apply(this, arguments); }
klass.addMethods=function(source) { var ancestor=this.superclass && this.superclass.prototype; for(var property in source) { if (ancestor && typeof(source[property])=="function") { var names = source[property].toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]; if(names.match(/^\s*\$super/)) { source[property] = (function(ancestorMethod, wrapper) { var am=ancestorMethod; return function() { var args=new Array(o2.FunctionBind(am, this)); for(var i=0; i<arguments.length; i++)
args.push(arguments[i]); return wrapper.apply(this, args); }
}) ((function(m) { return function() { return ancestor[m].apply(this, arguments); }; })(property), source[property]); }
}
this.prototype[property] = source[property]; }
if(typeof(source.toString)=="function" && source.toString!=Object.prototype.toString)
this.prototype.toString=source.toString; return this; }; klass.superclass = parent; klass.subclasses = []; if (parent) { var subclass = function() { }; subclass.prototype = parent.prototype; klass.prototype = new subclass; parent.subclasses.push(klass); }
for (var i = 0; i < properties.length; i++)
klass.addMethods(properties[i]); if (!klass.prototype.initialize)
klass.prototype.initialize = o2.Env.emptyFunction; klass.prototype.constructor = klass; return klass; }
o2.Event={ KEY_BACKSPACE: 8, KEY_TAB:       9, KEY_RETURN:   13, KEY_SHIFT:    16, KEY_ESC:      27, KEY_LEFT:     37, KEY_UP:       38, KEY_RIGHT:    39, KEY_DOWN:     40, KEY_DELETE:   46, KEY_HOME:     36, KEY_END:      35, KEY_PAGEUP:   33, KEY_PAGEDOWN: 34, KEY_INSERT:   45, cache: { }
}; o2.Event.Methods = (function() { var isButton; if (o2.Env.Browser.IE) { var buttonMap = { 0: 1, 1: 4, 2: 2 }; isButton = function(event, code) { return event.button == buttonMap[code]; }; } else if (o2.Env.Browser.WebKit) { isButton = function(event, code) { switch (code) { case 0: return event.which == 1 && !event.metaKey; case 1: return event.which == 1 && event.metaKey; default: return false; }
}; } else { isButton = function(event, code) { return event.which ? (event.which === code + 1) : (event.button === code); }; }
return { isLeftClick:   function(event) { return isButton(event, 0) }, isMiddleClick: function(event) { return isButton(event, 1) }, isRightClick:  function(event) { return isButton(event, 2) }, element: function(event) { event = o2.Event.extend(event); var node          = event.target, type          = event.type, currentTarget = event.currentTarget; if (currentTarget && currentTarget.tagName) { if (type === 'load' || type === 'error' ||
(type === 'click' && currentTarget.tagName.toLowerCase() === 'input' && currentTarget.type === 'radio'))
node = currentTarget; }
if (node.nodeType == 3)
node = node.parentNode; return node; }, pointer: function(event) { var docElement = document.documentElement, body = document.body || { scrollLeft: 0, scrollTop: 0 }; return { x: event.pageX || (event.clientX +
(docElement.scrollLeft || body.scrollLeft) -
(docElement.clientLeft || 0)), y: event.pageY || (event.clientY +
(docElement.scrollTop || body.scrollTop) -
(docElement.clientTop || 0)) }; }, stop: function(event) { if(!event.stopped) { o2.Event.extend(event); event.preventDefault(); event.stopPropagation(); event.stopped = true; }
}
}; })(); o2.Event.extend = (function() { if (o2.Env.Browser.IE) { var methods={ stopPropagation: function() { this.cancelBubble = true }, preventDefault:  function() { this.returnValue = false }, inspect: function() { return "[object Event]" }
}; return function(event) { if (!event) return false; if (event._extendedByo2prototype) return event; event._extendedByo2prototype = o2.Env.emptyFunction; var pointer = o2.Event.pointer(event); o2.ObjectExtend(event, { target: event.srcElement, pageX:  pointer.x, pageY:  pointer.y
}); return o2.ObjectExtend(event, methods); }; } else { return o2.Env.echoFunction; }
})(); o2.ObjectExtend(o2.Event, (function() { var cache = o2.Event.cache; function getEventID(element) { if (element._prototypeEventID) return element._prototypeEventID[0]; arguments.callee.id = arguments.callee.id || 1; return element._prototypeEventID = [++arguments.callee.id]; }
function getDOMEventName(eventName) { if (eventName && eventName.indexOf(':')>-1) return "dataavailable"; return eventName; }
function getCacheForID(id) { return cache[id] = cache[id] || { }; }
function getWrappersForEventName(id, eventName) { var c = getCacheForID(id); return c[eventName] = c[eventName] || []; }
function createWrapper(element, eventName, handler) { var id = getEventID(element); var c = getWrappersForEventName(id, eventName); var len=c.length; while(len--)
if(c[len].handler==handler)
return false; var wrapper = function(event) { if (!o2.Event || !o2.Event.extend || (event.eventName && event.eventName!=eventName))
return false; o2.Event.extend(event); handler.call(element, event); }; wrapper.handler = handler; c.push(wrapper); return wrapper; }
function findWrapper(id, eventName, handler) { var c = getWrappersForEventName(id, eventName); for(var i=0; i<c.length; i++)
if(c[i].handler == handler)
return c[i]; }
function destroyWrapper(id, eventName, handler) { var c = getCacheForID(id); if (!c[eventName])
return false; var wrapper=findWrapper(id, eventName, handler); var wrappers=c[eventName]; for(var i=0, len=wrappers.length; i<len; i++) { if(wrappers[i]==wrapper) { delete wrappers[i]; i++; for(; i<len; i++) { wrappers[i-1]=wrappers[i]; }
delete wrappers[i]; wrappers.length=wrappers.length-1; }
}
c[eventName]=wrappers; }
function destroyCache() { for (var id in cache)
for (var eventName in cache[id])
cache[id][eventName] = null; }
if (window.attachEvent) { window.attachEvent("onunload", destroyCache); }
if (o2.Env.Browser.WebKit) { window.addEventListener('unload', o2.Env.emptyFunction, false); }
return { observe: function(element, eventName, handler) { var name = getDOMEventName(eventName); var wrapper = createWrapper(element, eventName, handler); if (!wrapper) return element; if (element.addEventListener) { element.addEventListener(name, wrapper, false); } else { element.attachEvent("on" + name, wrapper); }
return element; }, stopObserving: function(element, eventName, handler) { var id = getEventID(element), name = getDOMEventName(eventName); var wrapper = findWrapper(id, eventName, handler); if (!wrapper) return element; if (element.removeEventListener) { element.removeEventListener(name, wrapper, false); } else { element.detachEvent("on" + name, wrapper); }
destroyWrapper(id, eventName, handler); return element; }
}; })()); o2.ObjectExtend(o2.Event, o2.Event.Methods); o2.Template=function(template) { this.template=template; }; o2.Template.prototype.evaluate=function(object) { var result=this.template; for(var property in object)
result=result.replace(new RegExp("#\{" + property + "\}", "gm"), object[property]); return result; }; o2.AlphaImage=function(img) { if (o2.Env.Browser.IE && !o2.Env.Browser.IE7)
return "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img + "',sizingMethod='crop');"; else
return "background: url(" + img + ") no-repeat;"; }; o2.ImageCache=function(src) { var img=new Image(); img.src=src; }; o2.EventDispatcher = o2.ClassCreate( { bindAsEventListener: function(object,eventname,func) { if(!this.observers)
this.observers=new Object(); if(this.observers[eventname])
this.observers[eventname].push([object,func]); else
this.observers[eventname]=[[object,func]]; }, trigger : function(event,oid) { if(!this.observers)
return; var observers = this.observers[event.e]; if(!(observers && observers.length))
return; var i = observers.length; while(i--) { if(oid) { if(observers[i][0].oid==parseInt(oid)) { observers[i][1].call(observers[i][0], event); return; }
} else
observers[i][1].call(observers[i][0], event); }
}, unBindEventListener:function(object, eventname, func) { if(this.observers[eventname]) { var observers = this.observers[eventname]; var len=observers.length; if(typeof(func)=="function")
while(len--) { if(observers[len][0]==object && observers[len][1]==func)
delete observers[len];}
else
while(len--)
if(observers[len][0]==object)
delete observers[len]; this.observers[eventname]=o2.ArrayCompact(observers); if(this.observers[eventname].length==0)
delete this.observers[eventname]; }
}
}); o2.AjaxRequester=o2.ClassCreate( { defaultOptions: { method:       'GET', asynchronous: true, contentType:  'application/x-www-form-urlencoded', encoding:     'UTF-8', params:   {}, evalJSON:     true, onSuccess:    function() {}, onFailure:    function() {}, onException:  function() {}
}, initialize:function(url, options) { this.options=o2.ObjectExtend({}, this.defaultOptions); this.setOptions(options); this.url = url; }, setOptions:function(options) { o2.ObjectExtend(this.options, options || {}); }, doRequest:function() { this.req = new o2.AjaxRequest(this.url,this.options); }, toString:function() { return "o2.AjaxRequester"; }
}); o2.AjaxTransport=function() { try{return new XMLHttpRequest();}catch(e){}
try{return new ActiveXObject('Msxml2.XMLHTTP');}catch(e){}
try{return new ActiveXObject('Microsoft.XMLHTTP');}catch(e){}
alert("Przeglądarka nie obsługuje XMLHttpRequest"); }; o2.AjaxRequest=o2.ClassCreate( { _complete:false, initialize:function(url,options) { this.transport = o2.AjaxTransport(); this.url = url; this.options = options; this.responseText=null; this.responseJSON=null; this.status=null; var params = options.params; if (params = o2.ObjectToQueryString(params)) { if (this.options.method == 'GET')
this.url += (this.url.indexOf('?')!=-1 ? '&' : '?') + params; else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
params += '&_='; }
try { this.transport.open(this.options.method, this.url, this.options.asynchronous); this.transport.onreadystatechange = o2.FunctionBind(this.onStateChange, this); if (this.options.method == 'POST') { this.transport.setRequestHeader('Content-type', this.options.contentType + (this.options.encoding ? '; charset=' + this.options.encoding : '')); if (this.transport.overrideMimeType && (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
this.transport.setRequestHeader('Connection','close'); }
this.transport.setRequestHeader('X-Requested-With','XMLHttpRequest'); this.transport.setRequestHeader('Accept','text/javascript, text/html, application/xml, text/xml, */*'); this.body = this.options.method == 'POST' ? (this.options.postBody || params) : null; this.transport.send(this.body); if (!this.options.asynchronous && this.transport.overrideMimeType)
this.onStateChange(); }
catch (e) { this.options.onFailure(this); }
}, onStateChange:function() { if (this.transport.readyState != 4 || this._complete)
return; try { this._complete = true; this.transformToResponse(); this.status = this.getStatus(); }
catch(e) { this.options.onFailure(this); }
if(200<=this.status && this.status<300) { if(this.responseJSON && this.responseJSON._e)
this.options.onException(this); else
this.options.onSuccess(this); } else { this.options.onFailure(this); }
}, getStatus: function() { try { return this.transport.status || 0; }
catch (e) { return 0
}
}, transformToResponse:function() { this.responseText=this.transport.responseText; if(this.responseText==null)
this.responseText=""; this.responseJSON=this._getResponseJSON(); }, _getResponseJSON:function() { var options = this.options; if (!options.evalJSON || (options.evalJSON != 'force' && (this.getHeader('Content-type') || '').indexOf('application/json')==-1) || this.responseText.match(/^\s*$/m))
return null; return this.evalJSON(this.responseText); }, evalJSON:function(responseText, sanitize) { var json=responseText.replace(o2.Env.JSONFilter, '#{1}'); try { if (this.isJSON(json))
return eval('(' + json + ')'); }
catch(e) { throw new SyntaxError('Badly formed JSON string: ' + responseText); }
}, isJSON: function(str) { if (str.match(/^\s*$/))
return false; str = str.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); }, getHeader:function(name) { try { return this.transport.getResponseHeader(name) || null; }
catch (e) { return null
}
}, toString:function() { return "o2.AjaxRequest"; }
}); o2.HamletRequester=o2.ClassCreate( { defaultOptions: { parameters:   {}, onSuccess:    function() {}, onFailure:    function() {}
}, initialize:function(url, options) { this.options=o2.ObjectExtend({}, this.defaultOptions); this.setOptions(options); this.url = url; }, setOptions:function(options) { o2.ObjectExtend(this.options, options || {}); }, doRequest:function() { this.req = new o2.HamletRequest(this.url, this.options); }, toString:function() { return "o2.HamletRequester"; }
}); o2.HamletDispatcher=new o2.EventDispatcher(); o2.HamletDispatcher.counter=0; o2.HamletRequest=o2.ClassCreate( { initialize: function(url, options) { options.parameters.oid=++o2.HamletDispatcher.counter; options.oid=o2.HamletDispatcher.counter; o2.HamletDispatcher.bindAsEventListener(options, 'load', options.onSuccess); o2.HamletDispatcher.bindAsEventListener(options, 'error', options.onFailure); var e = document.createElement("script"); e.src = url+'?'+o2.ObjectToQueryString(options.parameters); document.body.appendChild(e); }, toString:function() { return "o2.HamletRequest"; }
}); o2.mapy=new Object(); o2.mapy.TileSize = 256.0; o2.mapy.DragScrollableAbstract = o2.ClassCreate({ defaultCursor: "default", initialize: function(element, context) { this.element=element; if(context==null)
this.context=this; else
this.context=context; }, rebuild: function() { try { if(this.element==document.body)
this.context.element.style.cursor=this.defaultCursor; else
this.element.style.cursor=this.defaultCursor; } catch(e) { }
this.context.dshToolBox=new Object(); if(this.funcMouseDown) { this.context.dshToolBox.eventMouseDown=o2.FunctionBindAsEventListener(this.funcMouseDown, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'mousedown', this.context.dshToolBox.eventMouseDown); }
if(this.funcMouseMove) { this.context.dshToolBox.eventMouseMove=o2.FunctionBindAsEventListener(this.funcMouseMove, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'mousemove', this.context.dshToolBox.eventMouseMove); }
if(this.funcMouseUp) { this.context.dshToolBox.eventMouseUp=o2.FunctionBindAsEventListener(this.funcMouseUp, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'mouseup', this.context.dshToolBox.eventMouseUp); }
if(this.funcMouseOver) { this.context.dshToolBox.eventMouseOver=o2.FunctionBindAsEventListener(this.funcMouseOver, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'mouseover', this.context.dshToolBox.eventMouseOver); }
if(this.funcMouseOut) { this.context.dshToolBox.eventMouseOut=o2.FunctionBindAsEventListener(this.funcMouseOut, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'mouseout', this.context.dshToolBox.eventMouseOut); }
if(this.funcClick) { this.context.dshToolBox.eventClick=o2.FunctionBindAsEventListener(this.funcClick, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'click', this.context.dshToolBox.eventClick); }
if(this.funcDblClick) { this.context.dshToolBox.eventDblClick=o2.FunctionBindAsEventListener(this.funcDblClick, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'dblclick', this.context.dshToolBox.eventDblClick); }
if(this.funcWheel) { this.context.dshToolBox.eventWheel=o2.FunctionBindAsEventListener(this.funcWheel, this.context, o2.FunctionBind(this.arbitraryMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'DOMMouseScroll', this.context.dshToolBox.eventWheel); o2.Event.observe(this.element, 'mousewheel', this.context.dshToolBox.eventWheel); }
}, destroy: function() { if(this.context.dshToolBox.eventMouseDown)
o2.Event.stopObserving(this.element, 'mousedown', this.context.dshToolBox.eventMouseDown); if(this.context.dshToolBox.eventMouseMove)
o2.Event.stopObserving(this.element, 'mousemove', this.context.dshToolBox.eventMouseMove); if(this.context.dshToolBox.eventMouseUp)
o2.Event.stopObserving(this.element, 'mouseup', this.context.dshToolBox.eventMouseUp); if(this.context.dshToolBox.eventMouseOver)
o2.Event.stopObserving(this.element, 'mouseover', this.context.dshToolBox.eventMouseOver); if(this.context.dshToolBox.eventMouseOut)
o2.Event.stopObserving(this.element, 'mouseout', this.context.dshToolBox.eventMouseOut); if(this.context.dshToolBox.eventClick)
o2.Event.stopObserving(this.element, 'click', this.context.dshToolBox.eventClick); if(this.context.dshToolBox.eventDblClick)
o2.Event.stopObserving(this.element, 'dblclick', this.context.dshToolBox.eventDblClick); if(this.context.dshToolBox.eventWheel) { o2.Event.stopObserving(this.element, 'DOMMouseScroll', this.context.dshToolBox.eventWheel); o2.Event.stopObserving(this.element, 'mousewheel', this.context.dshToolBox.eventWheel); }
delete this.context.dshToolBox; }, transpMouseData: function(event) { var x=event.layerX || event.offsetX; var y=event.layerY || event.offsetY; var mapdivPoint = new o2.mapy.MapDivPoint(x-this.mapdiv._minx, y-this.mapdiv._miny); return {lnglat: mapdivPoint.getLngLat(this), mapdiv_point: mapdivPoint, b: o2.Event.isLeftClick(event), element: o2.Event.element(event)}; }, arbitraryMouseData: function(event) { var cumulativeOffsetX=0; var cumulativeOffsetY=0; var element=this.slot; do { cumulativeOffsetX += element.offsetLeft || 0; cumulativeOffsetY += element.offsetTop  || 0; element = element.offsetParent; } while (element); var pointer=o2.Event.pointer(event); var mapdivPoint=new o2.mapy.MapDivPoint(	pointer.x-cumulativeOffsetX-this.mapdiv._minx, pointer.y-cumulativeOffsetY-this.mapdiv._miny); var viewportPoint=new o2.mapy.ViewPortPoint(	pointer.x-cumulativeOffsetX, pointer.y-cumulativeOffsetY); return {lnglat: mapdivPoint.getLngLat(this), mapdiv_point: mapdivPoint, viewport_point: viewportPoint, b: o2.Event.isLeftClick(event), element: o2.Event.element(event)}; }, relativeMouseData: function(event) { var mapOffsetX=event.layerX || event.offsetX; var mapOffsetX=event.layerY || event.offsetY; var element=o2.Event.element(event); do { mapOffsetX += element.offsetLeft || 0; mapOffsetY += element.offsetTop  || 0; element = element.offsetParent; } while (element!=this.slot); var mapdivPoint=new o2.mapy.MapDivPoint(mapOffsetX-this.mapdiv._minx, mapOffsetY-this.mapdiv._miny); var viewportPoint=new o2.mapy.ViewPortPoint(mapOffsetX, mapOffsetY); return {lnglat: mapdivPoint.getLngLat(this), mapdiv_point: mapdivPoint, viewport_point: viewportPoint, b: o2.Event.isLeftClick(event), element: o2.Event.element(event)}; }, triggerArtEvent: function(event, eventName) { event.e=eventName; this.trigger(event); }, toString: function() { return "o2.mapy.DragScrollableAbstract"; }
}); o2.mapy.DragScrollableStandard=o2.ClassCreate(o2.mapy.DragScrollableAbstract, { defaultCursor: 'url(http://mapapi.o2.pl/api/images/cursors/openhand.cur?rev=3571), pointer', rebuild: function($super) { $super(); this.context.dshToolBox.scrollMouseMove=o2.FunctionBindAsEventListener(this.scroll, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); this.context.dshToolBox.scrollMouseUp=o2.FunctionBindAsEventListener(this.endScroll, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); this.context.dshToolBox.noScrollMouseMove=o2.FunctionBindAsEventListener(this.startScroll, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); this.context.dshToolBox.noScrollMouseUp=o2.FunctionBindAsEventListener(this.noScroll, this.context, o2.FunctionBind(this.transpMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); }, funcMouseDown: function(event, mouseData, eventTrigger) { var pointer=o2.Event.pointer(event); this.dshToolBox.startPointer=pointer; this.dshToolBox.pointer=pointer; this.element.style.cursor = 'url(http://mapapi.o2.pl/api/images/cursors/closedhand.cur?rev=3571), move'; o2.Event.stopObserving(this.element, 'mousemove', this.context.dshToolBox.eventMouseMove); o2.Event.observe(document.body, 'mousemove', this.dshToolBox.noScrollMouseMove); o2.Event.observe(document.body, 'mouseup', this.dshToolBox.noScrollMouseUp); o2.Event.stop(event); }, startScroll: function(event, mouseData, eventTrigger) { o2.Event.stopObserving(document.body, 'mousemove', this.dshToolBox.noScrollMouseMove); o2.Event.stopObserving(document.body, 'mouseup', this.dshToolBox.noScrollMouseUp); o2.Event.observe(document.body, 'mousemove', this.dshToolBox.scrollMouseMove); o2.Event.observe(document.body, 'mouseup', this.dshToolBox.scrollMouseUp); var pointer=o2.Event.pointer(event); this.map.move(pointer.x-this.dshToolBox.pointer.x, pointer.y-this.dshToolBox.pointer.y); this.dshToolBox.pointer=pointer; eventTrigger(mouseData(event), "movestart"); o2.Event.stop(event); }, noScroll: function(event, mouseData, eventTrigger) { o2.Event.stopObserving(document.body, 'mousemove', this.dshToolBox.noScrollMouseMove); o2.Event.stopObserving(document.body, 'mouseup', this.dshToolBox.noScrollMouseUp); this.element.style.cursor = 'url(http://mapapi.o2.pl/api/images/cursors/openhand.cur?rev=3571), pointer'; o2.Event.observe(this.element, 'mousemove', this.context.dshToolBox.eventMouseMove); eventTrigger(mouseData(event), "click"); o2.Event.stop(event); }, scroll: function(event, mouseData, eventTrigger) { var pointer=o2.Event.pointer(event); this.map.move(pointer.x-this.dshToolBox.pointer.x, pointer.y-this.dshToolBox.pointer.y); this.dshToolBox.pointer=pointer; o2.Event.stop(event); }, endScroll: function(event, mouseData, eventTrigger) { o2.Event.stop(event)
this.element.style.cursor = 'url(http://mapapi.o2.pl/api/images/cursors/openhand.cur?rev=3571), pointer'; o2.Event.stopObserving(document.body, 'mousemove', this.dshToolBox.scrollMouseMove); o2.Event.stopObserving(document.body, 'mouseup', this.dshToolBox.scrollMouseUp); o2.Event.observe(this.element, 'mousemove', this.context.dshToolBox.eventMouseMove); eventTrigger({vector: [this.dshToolBox.pointer.x-this.dshToolBox.startPointer.x, this.dshToolBox.pointer.y-this.dshToolBox.startPointer.y]}, "moveend"); }, funcMouseMove: function(event, mouseData, eventTrigger) { o2.Event.stop(event); eventTrigger(mouseData(event), "mousemove"); }, funcDblClick: function(event, mouseData, eventTrigger) { this.map.zoomin((mouseData(event))['lnglat']); o2.Event.stop(event); }, funcWheel: function(event, mouseData, eventTrigger) { var delta = 0; if (event.wheelDelta)
delta = event.wheelDelta/120; else if (event.detail)
delta = -event.detail/3; if (delta!=0)
if (delta < 0)
this.map.zoomout(); else
this.map.zoomin(); o2.Event.stop(event); event.returnValue = false; }, toString: function() { return "o2.mapy.DragScrollableStandard"; }
}); o2.mapy.DragScrollableFreez=o2.ClassCreate(o2.mapy.DragScrollableAbstract, { funcDblClick: function(event, mouseData, eventTrigger) { o2.Event.stop(event); this.map.zoomin((mouseData(event)).lnglat); }, toString: function() { return "o2.mapy.DragScrollableFreez"; }
}); o2.mapy.DragScrollableDummy=o2.ClassCreate(o2.mapy.DragScrollableAbstract, { funcMouseUp: function(event, mouseData, eventTrigger) { o2.Event.stop(event); eventTrigger(mouseData(event), "mouseup"); }, funcMouseMove: function(event, mouseData, eventTrigger) { o2.Event.stop(event); eventTrigger(mouseData(event), "mousemove"); }, funcMouseOver: function(event, mouseData, eventTrigger) { o2.Event.stop(event); eventTrigger(mouseData(event), "mouseover"); }, funcMouseOut: function(event, mouseData, eventTrigger) { o2.Event.stop(event); eventTrigger(mouseData(event), "mouseout"); }, funcClick: function(event, mouseData, eventTrigger) { o2.Event.stop(event); eventTrigger(mouseData(event), "click"); }, funcDblClick: function(event, mouseData, eventTrigger) { o2.Event.stop(event); eventTrigger(mouseData(event), "dblclick"); }, toString: function() { return "o2.mapy.DragScrollableDummy"; }
}); o2.mapy.LngLat=function(lng, lat) { this.lng = parseFloat(lng); this.lat = parseFloat(lat); }; o2.mapy.LngLat.prototype.getMapDivPoint=function(map) { var tc = new o2.mapy.TileCoords(map.mapdiv.zoom); var p = tc.tileToGeo(map.mapdiv._rootx, map.mapdiv._rooty); var r = o2.mapy.Projection.fromLLtoPixel([p[0][0], p[1][1]], map.mapdiv.zoom); var q = o2.mapy.Projection.fromLLtoPixel([this.lng, this.lat], map.mapdiv.zoom); return new o2.mapy.MapDivPoint(q[0]-r[0],q[1]-r[1]); }; o2.mapy.LngLat.prototype.getViewPortPoint=function(map) { var tc = new o2.mapy.TileCoords(map.mapdiv.zoom); var p = tc.tileToGeo(map.mapdiv._rootx, map.mapdiv._rooty); var r = o2.mapy.Projection.fromLLtoPixel([p[0][0], p[1][1]], map.mapdiv.zoom); var q = o2.mapy.Projection.fromLLtoPixel([this.lng, this.lat], map.mapdiv.zoom); return new o2.mapy.ViewPortPoint(q[0]-r[0]+map.mapdiv._minx, q[1]-r[1]+map.mapdiv._miny); }; o2.mapy.LngLat.prototype.getDistance=function(ll) { return o2.mapy.LngLat.getDistance(this, ll); }; o2.mapy.LngLat.prototype.toString=function() { return this.lng + "," + this.lat; }; o2.mapy.LngLat.getDistance = function(ll1,ll2) { var R = 6372.795; var dLat = (ll2.lat-ll1.lat)*Math.PI/180; var dLng = (ll2.lng-ll1.lng)*Math.PI/180; lat1 = ll1.lat*Math.PI/180; lat2 = ll2.lat*Math.PI/180; var a = Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(lat1)*Math.cos(lat2)*Math.sin(dLng/2)*Math.sin(dLng/2); var c = 2*Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R*c; return d; }; o2.mapy.LngLat.getPixelDistance = function(ll1,ll2,zoom) { var r1 = o2.mapy.Projection.fromLLtoPixel([ll1.lng,ll1.lat],zoom)
var r2 = o2.mapy.Projection.fromLLtoPixel([ll2.lng,ll2.lat],zoom)
var dx = Math.abs(r1[0]-r2[0]); var dy = Math.abs(r1[1]-r2[1]); var f = {'d':Math.sqrt(dx*dx+dy*dy),'dx':dx,'dy':dy}
return f
}
o2.mapy.MapDivPoint=function(x, y) { this.x = parseInt(x); this.y = parseInt(y); }; o2.mapy.MapDivPoint.prototype.subtract=function(point) { this.x -= point.x; this.y -= point.y; return this; }; o2.mapy.MapDivPoint.prototype.sum=function(point) { this.x += point.x; this.y += point.y; return this; }; o2.mapy.MapDivPoint.prototype.toString=function() { return this.x + "," + this.y; }; o2.mapy.MapDivPoint.prototype.getLngLat=function(map) { var tc = new o2.mapy.TileCoords(map.mapdiv.zoom); var p = tc.tileToGeo(map.mapdiv._rootx, map.mapdiv._rooty); var r = o2.mapy.Projection.fromLLtoPixel([p[0][0], p[1][1]], map.mapdiv.zoom); var k = o2.mapy.Projection.fromPixelToLL([r[0]+this.x, r[1]+this.y], map.mapdiv.zoom); return new o2.mapy.LngLat(k[0],k[1]); }; o2.mapy.MapDivPoint.prototype.getViewPortPoint=function(map) { return new o2.mapy.ViewPortPoint(this.x+map.mapdiv._minx, this.y+map.mapdiv._miny); }; o2.mapy.MapDivPoint.subtract = function(point1,point2) { return new o2.mapy.MapDivPoint(point1.x-point2.x, point1.y-point2.y); }; o2.mapy.MapDivPoint.sum = function(point1,point2) { return new o2.mapy.MapDivPoint(point1.x+point2.x, point1.y+point2.y); }; o2.mapy.ViewPortPoint=function(x, y) { this.x = parseInt(x); this.y = parseInt(y); }; o2.mapy.ViewPortPoint.prototype.subtract=function(point) { this.x -= point.x; this.y -= point.y; return this; }; o2.mapy.ViewPortPoint.prototype.sum=function(point) { this.x += point.x; this.y += point.y; return this; }; o2.mapy.ViewPortPoint.prototype.toString=function() { return this.x + "," + this.y; }; o2.mapy.ViewPortPoint.prototype.getLngLat=function(map) { var tc = new o2.mapy.TileCoords(map.mapdiv.zoom); var p = tc.tileToGeo(map.mapdiv._rootx, map.mapdiv._rooty); var r = o2.mapy.Projection.fromLLtoPixel([p[0][0], p[1][1]], map.mapdiv.zoom); var k = o2.mapy.Projection.fromPixelToLL([r[0]+this.x-map.mapdiv._minx, r[1]+this.y-map.mapdiv._miny], map.mapdiv.zoom); return new o2.mapy.LngLat(k[0],k[1]); }; o2.mapy.ViewPortPoint.prototype.getMapDivPoint=function(map) { return new o2.mapy.MapDivPoint(this.x-map.mapdiv._minx, this.y-map.mapdiv._miny); }; o2.mapy.ViewPortPoint.subtract = function(point1,point2) { return new o2.mapy.ViewPortPoint(point1.x-point2.x, point1.y-point2.y); }; o2.mapy.ViewPortPoint.sum = function(point1,point2) { return new o2.mapy.ViewPortPoint(point1.x+point2.x, point1.y+point2.y); }; o2.mapy.Size=function(width, height) { this.height = height; this.width  = width; }; o2.mapy.Size.prototype.getWidthString=function() { if(this.width=="auto")
return "auto"; else
return this.width + "px"; }; o2.mapy.Size.prototype.getHeightString=function() { if(this.height=="auto")
return "auto"; else
return this.height + "px"; }; o2.mapy.Size.prototype.toString=function() { return this.width + "," + this.height; }; o2.mapy.PositionStrategy = o2.ClassCreate({ initialize:function() { }, getPosition:function() { throw new Error("Nie zadeklarowano metody pozyskiwania pozycji"); }, toString: function() { return "o2.mapy.PositionStrategy"; }
}); o2.mapy.FixedPositionStrategy = o2.ClassCreate(o2.mapy.PositionStrategy,{ initialize:function(point) { this.point=point; }, getPosition:function(object) { return this.point; }, toString: function() { return "o2.mapy.FixedPositionStrategy"; }
}); o2.mapy.FloatPositionStrategy = o2.ClassCreate(o2.mapy.PositionStrategy,{ initialize:function(displacement){ if(displacement) { this.displacement = displacement
}
else { this.displacement = new o2.mapy.ViewPortPoint(0,0) }
}, getPosition:function(object) { return new o2.mapy.ViewPortPoint(0,0).sum(this.displacement); }, toString: function() { return "o2.mapy.FloatPositionStrategy"; }
}); o2.mapy.LeftMiddlePositionStrategy = o2.ClassCreate(o2.mapy.FloatPositionStrategy,{ getPosition:function(object) { var size=object.elementSize(); var x=0
var y=object.map.getViewPortHeight()/2 - size.height/2; return new o2.mapy.ViewPortPoint(x,y).sum(this.displacement); }, toString: function() { return "o2.mapy.LeftMiddlePositionStrategy"; }
}); o2.mapy.CenterMiddlePositionStrategy = o2.ClassCreate(o2.mapy.FloatPositionStrategy,{ getPosition:function(object) { var size=object.elementSize(); var x=object.map.getViewPortWidth()/2 - size.width/2; var y=object.map.getViewPortHeight()/2 - size.height/2; return new o2.mapy.ViewPortPoint(x,y).sum(this.displacement); }, toString: function() { return "o2.mapy.CenterMiddlePositionStrategy"; }
}); o2.mapy.CenterBottomPositionStrategy = o2.ClassCreate(o2.mapy.FloatPositionStrategy,{ getPosition:function(object) { var size=object.elementSize(); var x=object.map.getViewPortWidth()/2 - size.width/2; var y=object.map.getViewPortHeight() - size.height; return new o2.mapy.ViewPortPoint(x,y).sum(this.displacement); }, toString: function() { return "o2.mapy.CenterBottomPositionStrategy"; }
}); o2.mapy.RightMiddlePositionStrategy = o2.ClassCreate(o2.mapy.FloatPositionStrategy,{ getPosition:function(object) { var size=object.elementSize(); var x=object.map.getViewPortWidth() - size.width; var y=object.map.getViewPortHeight()/2 - size.height/2; return new o2.mapy.ViewPortPoint(x,y).sum(this.displacement); }, toString: function() { return "o2.mapy.RightMiddlePositionStrategy"; }
}); o2.mapy.LeftBottomPositionStrategy = o2.ClassCreate(o2.mapy.FloatPositionStrategy,{ getPosition:function(object) { var size=object.elementSize(); var x=0; var y=object.map.getViewPortHeight() - size.height; return new o2.mapy.ViewPortPoint(x,y).sum(this.displacement); }, toString: function() { return "o2.mapy.LeftBottomPositionStrategy"; }
}); o2.mapy.RightBottomPositionStrategy = o2.ClassCreate(o2.mapy.FloatPositionStrategy,{ getPosition:function(object) { var size=object.elementSize(); var x=object.map.getViewPortWidth() - size.width; var y=object.map.getViewPortHeight() - size.height; return new o2.mapy.ViewPortPoint(x,y).sum(this.displacement); }, toString: function() { return "o2.mapy.RightBottomPositionStrategy"; }
}); o2.mapy.LeftTopPositionStrategy = o2.mapy.FloatPositionStrategy; o2.mapy.CenterTopPositionStrategy = o2.ClassCreate(o2.mapy.FloatPositionStrategy,{ getPosition:function(object) { var size=object.elementSize(); var x=object.map.getViewPortWidth()/2 - size.width/2; var y=0; return new o2.mapy.ViewPortPoint(x,y).sum(this.displacement); }, toString: function() { return "o2.mapy.CenterTopPositionStrategy"; }
}); o2.mapy.RightTopPositionStrategy = o2.ClassCreate(o2.mapy.FloatPositionStrategy,{ getPosition:function(object) { var size=object.elementSize(); var x=object.map.getViewPortWidth() - size.width; var y=0; return new o2.mapy.ViewPortPoint(x,y).sum(this.displacement); }, toString: function() { return "o2.mapy.RightTopPositionStrategy"; }
}); o2.mapy.Layer = o2.ClassCreate(o2.EventDispatcher, { group: "Layer", defaultOptions: {}, defaultControllers: function() { return new Array(); }, template: null, initialize: function(element, options) { this.isDrawn=false; this.options=o2.ObjectExtend({}, this.defaultOptions); this.options.style=new Object(); this.options.panmapstrategy=new Object(); this.options.content=new Object(); o2.ObjectExtend(this.options.style, this.defaultOptions.style); o2.ObjectExtend(this.options.panmapstrategy, this.defaultOptions.panmapstrategy); o2.ObjectExtend(this.options.content, this.defaultOptions.content); if(options instanceof Object)
o2.ObjectMerge(this.options, options, "style", "panmapstrategy", "content", "shadow"); this.setElements(element); this.controllers=this.defaultControllers(); this.setElement(this.element); }, setHTML:function(html) { var div = document.createElement('div'); o2.ElementUpdateString(div, html); this.element=div; }, setElements: function(element) { if(element && element.nodeType==1) { this.element = element; } else if(this.template && this.options.substitute) { this.setHTML(this.template.evaluate(this.options.substitute)); } else if(typeof(element)=="string") { this.setHTML(element); } else { throw new Error("Nieprawidłowy element argument: " + element); }
}, setElement:function(element) { o2.ObjectExtend(element.style, this.options.style); if(this.options.size instanceof o2.mapy.Size) { element.style.width=this.options.size.getWidthString(); element.style.height=this.options.size.getHeightString(); }
if(this.options.style&&this.options.style.backgroundImage && o2.Env.Browser.IE && !o2.Env.Browser.IE7 && !this.options.style.backgroundPosition) { this.element.style.backgroundImage="none"; element.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
this.options.style.backgroundImage.match(/^url\((.+)\)$/)[1] + "',sizingMethod='crop');"; }
if(this.options.style&&this.options.style.opacity && o2.Env.Browser.IE)
element.style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity=" + this.options.style.opacity*100 + ")"; this.element=element; element.style.position='absolute'; }, elementSize: function() { var borderWidth=parseInt(this.element.style.borderWidth) || 0; if(this.isDrawn) { var size=new o2.mapy.Size(
this.element.clientWidth+2*borderWidth, this.element.clientHeight+2*borderWidth
); } else { var orygVisibility=this.element.style.visibility; this.element.style.visibility="hidden"; this.parente._element.appendChild(this.element); var size=new o2.mapy.Size(
this.element.clientWidth+2*borderWidth, this.element.clientHeight+2*borderWidth
); this.parente._element.removeChild(this.element); this.element.style.visibility=orygVisibility; }
return size; }, draw:function() { this.parente.attach(this); this.activateController.apply(this, this.controllers); this.isDrawn=true; }, attach:function(element) { if(element instanceof o2.mapy.Layer)
element = element.getElement(); var attachpath = this.options.attachpath; if(typeof(attachpath)=="undefined") { this.element.appendChild(element); return; }
if(attachpath.indexOf(".")>0) { var path=attachpath.split("."); o2.ElementSelect(this.element, path[0], path[1])[0].appendChild(element); return; }
if(attachpath.indexOf("#")==0) { document.getElementById(attachpath.substr(1)).appendChild(element); return; }
if(attachpath.match(/^[^\s]+$/)) { o2.ElementSelect(this.element, attachpath, "")[0].appendChild(element); return; }
throw new Error("Nieprawidłowy format wartości klucza 'path' słownika kontrolera."); }, activateController: function() { var len=arguments.length; while(len--) { var attachpath = arguments[len].path; if(typeof(attachpath)=="undefined") { arguments[len].bindElement=this.element; } else if(attachpath.indexOf(".")>0) { var path=attachpath.split("."); arguments[len].bindElement=o2.ElementSelect(this.element, path[0], path[1])[0]; } else if(attachpath.indexOf("#")==0) { arguments[len].bindElement=document.getElementById(attachpath.substr(1)); } else if(attachpath.match(/^\S+$/)) { arguments[len].bindElement=o2.ElementSelect(this.element, attachpath, "")[0]; }
if(arguments[len].bindElement)
o2.Event.observe(arguments[len].bindElement, arguments[len].event, arguments[len].func); else
throw Error("Element do podpięcia kontrolera nie został znaleziony " + attachpath); }
}, addController:function() { var len=arguments.length; while(len--) { this.controllers.push(arguments[len]); if(this.isDrawn)
this.activateController(this.controllers[this.controllers.length-1]); }
}, deactivateController: function() { var len=arguments.length; while(len--) { if(!arguments[len].bindElement)
continue; o2.Event.stopObserving(arguments[len].bindElement, arguments[len].event, arguments[len].func); }
}, removeController: function() { var arglen=arguments.length; var conlen; while(arglen--) { conlen=this.controllers.length; while(conlen--) { if(arguments[arglen]==this.controllers[conlen]) { if(this.isDrawn)
this.deactivateController(this.controllers[conlen]); delete this.controllers[conlen]; }
}
}
this.controllers=o2.ArrayCompact(this.controllers); }, selectController: function(controllers, controllerPattern) { var result=new Array(); var other; var len=controllers.length; while(len--) { other=false; for(var key in controllerPattern)
if(controllerPattern[key]!=controllers[len][key])
other=true; if(!other)
result.push(controllers[len]); }
return result; }, clear: function() { this.deactivateController.apply(this, this.controllers); this.parente.detach(this); this.isDrawn=false; }, destroy: function() { delete this.element; }, toString: function() { return "o2.mapy.Layer"; }
}); o2.mapy.MapStaticLayer = o2.ClassCreate(o2.mapy.Layer, { group: "MapStaticLayer", defaultOptions: { clickable: true, positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(0, 0)), style: {}
}, draw: function($super) { if(!this.map) { throw new Error("Brak obiektu mapy"); }
this.refresh(); $super() }, setMap:function(map) { this.map = map
if(this.options.clickable) { this.parente = this.map.clickablestaticlay
}
else { this.parente = this.map.nonclickablestaticlay
}
if(this.toolTip)
this.toolTip.setMap(map); }, refresh:function() { var position = this.options.positioner.getPosition(this); this.element.style.top=position.y + 'px'; this.element.style.left=position.x + 'px'; }, toString: function() { return "o2.mapy.MapStaticLayer"; }
}); o2.mapy.MapMovableLayer = o2.ClassCreate(o2.mapy.Layer, { group: "MapMovableLayer", defaultOptions: { clickable: true, draggable: false, displacement: "0, 0", style: {}, size: new o2.mapy.Size(100, 100), panmapstrategy: { type: "none"
}
}, initialize: function($super, point, element, options) { this.point=point; $super(element, options); if(this.options.clickable) { if(this.options.draggable) { this.dsh=new o2.mapy.DragScrollableLayerMove(document.body, this); this.element.style.cursor="url(http://mapapi.o2.pl/api/images/cursors/openhandmarker.cur?rev=3571), default"; } else { this.dsh=new o2.mapy.DragScrollableLayerHold(document.body, this); }
this.funcMouseMove=o2.FunctionBindAsEventListener(this.dragFunctions.onMouseMove, this); this.funcMouseUp=o2.FunctionBindAsEventListener(this.dragFunctions.onMouseUp, this); this.addController( { event: "mousedown", func: o2.FunctionBindAsEventListener(this.dragFunctions.onMouseDown, this) }
); }
}, elementDisplacement: function() { var size=this.elementSize(); var x, y; var displacements=this.options.displacement.split(","); if(displacements[0].indexOf("s")>-1)
x=size.width; else
x=0; if(displacements[1].indexOf("s")>-1)
y=size.height; else
y=0; return new o2.mapy.ViewPortPoint(
x + parseInt(displacements[0]), y + parseInt(displacements[1])
); }, draw: function($super) { if(!this.map) { throw new Error("Brak obiektu mapy"); }
this.refresh(); $super(); this.panMapFunctions[this.options.panmapstrategy.type].call(this); }, refresh:function() { var pos = this.point.getMapDivPoint(this.map); pos.subtract(this.elementDisplacement()); this.element.style.left = pos.x+'px'; this.element.style.top = pos.y+'px'; }, setMap:function(map) { this.map = map; if(this.options.clickable)
this.parente = this.map.clickmovable; else
this.parente = this.map.nonclickmovable; }, toString: function() { return "o2.mapy.MapMovableLayer"; }, dragFunctions: { onMouseDown:function(event) { var size=this.elementSize(); var displacement=this.elementDisplacement(); this.fix = new o2.mapy.MapDivPoint(
displacement.x-size.width/2, displacement.y-size.height/2
); o2.Event.observe(this.element, 'mousemove', this.funcMouseMove); o2.Event.observe(this.element, 'mouseup', this.funcMouseUp); o2.Event.observe(this.element, 'mouseout', this.funcMouseMove); }, onMouseMove: function(event) { this.map.loadDsh(this.dsh); o2.Event.stopObserving(this.element, 'mousemove', this.funcMouseMove); o2.Event.stopObserving(this.element, 'mouseup', this.funcMouseUp); o2.Event.stopObserving(this.element, 'mouseout', this.funcMouseMove); }, onMouseUp:function(event) { o2.Event.stopObserving(this.element, 'mousemove', this.funcMouseMove); o2.Event.stopObserving(this.element, 'mouseup', this.funcMouseUp); o2.Event.stopObserving(this.element, 'mouseout', this.funcMouseMove); this.trigger({e: 'click'}); }
}, panMapFunctions: { none: function() { }, toviewport: function() { var top=this.options.panmapstrategy.top || 0; var right=this.options.panmapstrategy.right || 0; var bottom=this.options.panmapstrategy.bottom || 0; var left=this.options.panmapstrategy.left || 0; var vpoint=this.point.getViewPortPoint(this.map); var size=this.elementSize(); var displacement=this.elementDisplacement(); var dx=0, dy=0; if(size.width>this.map.mapdiv.vpsize.width || size.height>this.map.mapdiv.vpsize.height) { this.panMapFunctions.tocenter(); return ; }
if(vpoint.x-displacement.x<left)
dx=vpoint.x-displacement.x-left; if(vpoint.x-displacement.x+size.width>this.map.mapdiv.vpsize.width-right)
dx=vpoint.x-displacement.x+size.width-this.map.mapdiv.vpsize.width+right; if(vpoint.y-displacement.y<top)
dy=vpoint.y-displacement.y-top; if(vpoint.y-displacement.y+size.height>this.map.mapdiv.vpsize.height-bottom)
dy=vpoint.y-displacement.y+size.height-this.map.mapdiv.vpsize.height+bottom; if(Math.abs(dx)>1.5*this.map.mapdiv.vpsize.width || Math.abs(dy)>1.5*this.map.mapdiv.vpsize.height) { var center=new o2.mapy.ViewPortPoint(
vpoint.x+size.width/2-displacement.x, vpoint.y+size.height/2-displacement.y
); this.map.setCenter(center.getLngLat(this.map), this.map.mapdiv.zoom); return ; }
this.map.panTo(this.map.getCenter(), -Math.round(dx), -Math.round(dy)); }, tocenter: function() { var vpoint=this.point.getViewPortPoint(this.map); var size=this.elementSize(); var displacement=this.elementDisplacement(); if(vpoint.x-displacement.x<-this.map.mapdiv.vpsize.width ||
vpoint.x-displacement.x+size.width>2*this.map.mapdiv.vpsize.width ||
vpoint.y-displacement.y<-this.map.mapdiv.vpsize.height ||
vpoint.y-displacement.y+size.height>2*this.map.mapdiv.vpsize.height) { var center=new o2.mapy.ViewPortPoint(
vpoint.x+size.width/2-displacement.x, vpoint.y+size.height/2-displacement.y
); this.map.setCenter(center.getLngLat(this.map), this.map.mapdiv.zoom); } else
this.map.panTo(this.point, displacement.x-Math.round(size.width/2), displacement.y-Math.round(size.height/2)); }
}
}); o2.mapy.MapAlert = o2.ClassCreate(o2.mapy.MapStaticLayer, { group:"MapAlert", defaultOptions:{ positioner: new o2.mapy.CenterMiddlePositionStrategy(), style: { border: 'solid white 1px', background: '#fff'
}, clickable: true
}, template: new o2.Template(
'<div style="border: solid black 1px">' +
'	<div class="close" style="position:absolute;top:7px;right:7px;width:20px;height:20px;background:url(http://mapapi.o2.pl/api/images/dymek_zamykanie.png?rev=3571) no-repeat"></div>' +
'	#{msg}' +
'	<div style="text-align:center;margin:20px 0px 20px 0px">' +
'		<div class="close_alert" style="background:url(http://mapapi.o2.pl/api/images/ok.gif?rev=3571) no-repeat;width:46px;height:27px;margin:0px auto"></div>' +
'	</div>' +
'</div>'
), defaultControllers: function() { return new Array( { path: "div.close_alert", event: "click", func: o2.FunctionBindAsEventListener(this.clear, this) }, { path: "div.close", event: "click", func: o2.FunctionBindAsEventListener(this.clear, this) }
); }, initialize:function($super, msg, options) { if(msg!=null) { if(!options)
options=new Object(); if(!options.substitute)
options.substitute=new Object(); options.substitute.msg=msg.toString(); }
$super('', options); }, setMap: function($super, map) { $super(map); this.dsh=new o2.mapy.DragScrollableAbstract(map.transp, null); }, draw: function($super) { $super(); this.map.loadDsh(this.dsh); }, clear: function($super) { this.map.unLoadDsh(this.dsh); $super(); }, toString: function() { return "o2.mapy.MapAlert"; }
}); o2.ImageCache("http://mapapi.o2.pl/api/images/dymek_zamykanie.png?rev=3571"); o2.ImageCache("http://mapapi.o2.pl/api/images/ok.gif?rev=3571"); o2.mapy.ZoomRefreshStrategy=function(mapdiv) { this.mapdiv=mapdiv; }; o2.mapy.ZoomRefreshStrategy.prototype.refresh=function(event) { this.setToBeginning(); var i=this.elements.length; while(i--)
if(this.elements[i]!=null)
this.elements[i].refresh(); }; o2.mapy.ZoomRefreshStrategy.prototype.setToBeginning=function() { this._element.style.left=this.mapdiv._minx + "px"; this._element.style.top=this.mapdiv._miny + "px"; }; o2.mapy.ZoomRefreshStrategy.prototype.toString=function() { return "o2.mapy.ZoomRefreshStrategy"; }; o2.mapy.ResizeRefreshStrategy=function() { }; o2.mapy.ResizeRefreshStrategy.prototype.refresh=function() { var i=this.elements.length; while(i--)
if(this.elements[i]!=null&&typeof(this.elements[i].refresh)!="undefined")
this.elements[i].refresh(); }; o2.mapy.ResizeRefreshStrategy.prototype.toString=function() { return "o2.mapy.ResizeRefreshStrategy"; }; o2.mapy.LaysContainer = o2.ClassCreate({ initialize: function(refreshstrategy,zindex) { this.elements = new Array(), this._element = document.createElement("div"); o2.ObjectExtend(this, refreshstrategy); o2.ObjectExtend(this._element.style, {width: 0, height: 0, position: "absolute", top: 0 + "px", left: 0+ "px", 'z-index': zindex}); this._element.style.zIndex=zindex; this.refresh() }, setMap:function(map) { this.map = map; }, getElement: function() { return this._element
}, attach: function(lay) { var group = lay.group; if (lay.options&& lay.options.single && this.getObjectsByGroup(lay.group).length != 0) { return 0; }
lay.markerlayid=this.elements.length; this.elements.push(lay); this._element.appendChild(lay.element); }, detach: function(lay) { this._element.removeChild(lay.element); var withoutArray=new Array(); for(var i=0; i<this.elements.length; i++)
if(lay!=this.elements[i])
withoutArray.push(this.elements[i]); this.elements=withoutArray; }, refresh: function() { this.refreshstrategy.apply(); }, clearGroup: function() { if(arguments.length==0) { var i=this.elements.length; while(i--)
if(this.elements[i] && this.elements[i].clear)
this.elements[i].clear(); this.elements=new Array(); } else { var elems=this.getObjectsByGroup.apply(this, arguments); var i=elems.length; while(i--) { if(elems[i] && elems[i].clear) { elems[i].clear(); elems[i]==null; }
}
this.elements=o2.ArrayCompact(this.elements); }
}, getObjectsByGroup: function() { var result=new Array(); if(arguments.length>0) { var args=Array.prototype.slice.call(arguments); var groups=new RegExp("^" + args.join("$|^") + "$"); var i=this.elements.length; for(var j=0; j<i; j++)
if(this.elements[j] && this.elements[j].group.match(groups))
result.push(this.elements[j]); }
return result; }, getByClass: function() { var result=new Array(); if(arguments.length!=0)
for (var i=0; i<arguments.length; i++)
for(var j=0; j<this.elements.length; j++)
if (this.elements[j] instanceof arguments[i])
result.push(this.elements[j]); return result; }, clearOid: function() { }, toString: function() { return "o2.mapy.LaysContainer"; }
}); o2.mapy.Tile = o2.ClassCreate(o2.EventDispatcher,{ tileRange: { 0: [3, 3], 1: [3, 3], 2: [4, 4], 3: [6, 5], 4: [10, 8], 5: [18, 14], 6: [34, 26], 7: [65, 50], 8: [127, 98], 9: [252, 194], 10: [501, 386], 11: [1000, 770], 12: [1998, 1537], 13: [3993, 3071], 14: [7983, 6139], 15: [15964, 12275]
}, initialize: function(zoom,rootx,rooty,gridcol,gridrow) { this.retryLimit=0; this.state = 0
this.position = null
this.index = [gridcol,gridrow]
this.root=[rootx,rooty]; this.zoom = zoom; this.range = this.tileRange[parseInt(zoom)-3]; this.element = new Image(); o2.ObjectExtend(this.element.style, {"position": "absolute", "width": o2.mapy.TileSize+"px", "height": o2.mapy.TileSize+"px", 'display':'none','top':0,'left':0}); }, initLoad:function() { this.update(this.root[0] + this.index[0],this.root[1] + this.index[1]) }, trigger:function($super,e) { if(!this.counter){ this.counter = {}
}
if(!this.counter[e['e']]) { this.counter[e['e']]=0
}
this.counter[e['e']]++
$super(e) }, onload:function(){ this.retryLimit=0; try{ this.element.style['display']='block'; this.element.style['width']  = o2.mapy.TileSize+"px"; this.element.style['height'] = o2.mapy.TileSize+"px"; this.element.style['z-index'] = 100
if(this.state!=2) { this.trigger({'e':'load'})
this.state = 2
}
}
catch(e){ }
}, update:function(tilex,tiley) { if(this.state==2||this.state==0) { this.trigger({'e':'start'}) }
this.state = 1; this.tilex = tilex
this.tiley = tiley
this.position = [(tilex-this.root[0])*o2.mapy.TileSize,(tiley-this.root[1])*o2.mapy.TileSize]
try { this.element.style['left'] = this.position[0]+'px'; this.element.style['top'] = this.position[1]+'px'; this.element.style['display']='none'
} catch(e) { }
if((tilex>=0 && tilex<this.range[0])&&(tiley>=0 && tiley<this.range[1])) { this.element.src = "http://t"+parseInt((tilex+tiley)%4+1)+".wmapa.pl/tile/"+(parseInt(this.zoom)-3)+","+(tiley+1)+","+(tilex+1); }
else { this.element.src = "http://t1"+".wmapa.pl/tile/1,0,0"; }
this.element.onload=o2.FunctionBind(this.onload, this)
this.element.onerror=o2.FunctionBind(this.retry, this)
if(this.element.complete) { this.element.onload() }
}, retry:function(){ this.retryLimit+=1; if(this.retryLimit<6)
this.update(this.tilex,this.tiley); }, refresh:function(zoom,rootx,rooty,x,y) { this.zoom = zoom
this.root=[rootx,rooty]
this.range = this.tileRange[parseInt(zoom)-3]
this.update(x+this.root[0],y+this.root[1]) }, changeRow:function(dy) { this.update(this.tilex,this.tiley+dy) }, changeCol:function(dx) { this.update(this.tilex+dx,this.tiley) }, resize:function(movex,movey,resize) { this.element.style.top  = (parseInt(this.element.style.top) - movey)+'px'
this.element.style.left = (parseInt(this.element.style.left) - movex)+'px'
this.element.style.width = (parseInt(this.element.style.width)+resize)+'px'
this.element.style.height = (parseInt(this.element.style.height)+resize)+'px'
this.element.style['z-index'] = 50
}, toString: function() { return "o2.mapy.Tile"; }
}); o2.mapy.Grid = o2.ClassCreate({ initialize:function(cols,rows,fillarr,creationOrder) { var r=0; this.rows=new Array(); while(r<rows) { this.rows.push(r); r++; }
var c=0; this.cols=new Array(); while(c<cols) { this.cols.push(c); c++; }
if(!creationOrder) { var creationOrder=this.defaultqueue(cols,rows) }
this.grid=[]
if(!fillarr) fillarr = [function(x,y){return x+' '+y},null]
for( var i=0; i<creationOrder.length;i++) { var x = creationOrder[i][0]
var y = creationOrder[i][1]
if(!this.grid[x]) this.grid[x]=[]
this.grid[x][y] = fillarr[0].apply(fillarr[1],[x,y]) }
}, getCell:function(col,row) { return this.grid[this.cols[col]][this.rows[row]]
}, getSize:function(){return [this.cols.length,this.rows.length]}, transferColumn:function(dir,funarr) { var dir = Math.round(dir/Math.abs(dir))
if(dir >0) { var colin = this.cols.shift()
this.cols.push(colin) }
else { var colin = this.cols.pop()
this.cols.unshift(colin) }
if(funarr) { col=o2.ArrayCompact(this.grid[colin]); funarr[0].apply(funarr[1],[col,this.cols.length*dir]) }
}, transferRow:function(dir,funarr) { var dir = Math.round(dir/Math.abs(dir))
if(dir >0) { var rowin = this.rows.shift()
this.rows.push(rowin) }
else { var rowin = this.rows.pop()
this.rows.unshift(rowin) }
if(funarr) { var row = []
for(var i=0; i<this.cols.length;i++) { row.push(this.grid[this.cols[i]][rowin]) }
funarr[0].apply(funarr[1],[row,this.rows.length*dir]) }
}, unshiftColumn:function(funarr) { var col = this.grid.length
this.grid[col] = []
for(var i =0; i<this.rows.length;i++) { this.grid[col][this.rows[i]]=funarr[0].apply(funarr[1],[0,i]) }
this.cols.unshift(col) }, unshiftRow:function(funarr) { var row = this.grid[this.cols[0]].length
for(var i =0; i<this.cols.length;i++) { this.grid[this.cols[i]][row]=funarr[0].apply(funarr[1],[i,0]) }
this.rows.unshift(row) }, pushColumn:function(funarr) { var col = this.grid.length
this.grid[col] = []
for(var i =0; i<this.rows.length;i++) { try{ this.grid[col][this.rows[i]]=funarr[0].apply(funarr[1],[this.cols.length,i]) }
catch(e){}
}
this.cols.push(col) }, pushRow:function(funarr) { var row = this.grid[this.cols[0]].length
for(var i =0; i<this.cols.length;i++) { this.grid[this.cols[i]][row]=funarr[0].apply(funarr[1],[i,this.rows.length]) }
this.rows.push(row) }, shiftColumn:function(funarr) { var col = this.cols.shift()
if(funarr) { funarr[0].apply(funarr[1],[o2.ArrayCompact(this.grid[col])]) }
delete this.grid[col]
}, shiftRow:function(funarr) { var row = this.rows.shift()
var rowcells  = []
for(var i=0;i<this.cols.length;i++) { rowcells.push(this.grid[this.cols[i]][row])
delete this.grid[this.cols[i]][row]
}
if(funarr) { funarr[0].apply(funarr[1],[rowcells]) }
}, popColumn:function(funarr) { var col = this.cols.pop()
if(funarr) { funarr[0].apply(funarr[1],[o2.ArrayCompact(this.grid[col])]) }
delete this.grid[col]
}, popRow:function(funarr) { var row = this.rows.pop()
var rows=[]
for(var i=0;i<this.cols.length;i++) { rows.push(this.grid[this.cols[i]][row])
delete this.grid[this.cols[i]][row]
}
if(funarr) { funarr[0].apply(funarr[1],[rows]) }
}, getGrid:function() { var ret = []
for(var i=0;i<this.cols.length;i++) { if(!ret[i]) ret[i]=[]
for(var j=0;j<this.rows.length;j++) { ret[i][j]=this.grid[this.cols[i]][this.rows[j]]
}
}
return ret
}, defaultqueue:function(cols,rows) { var creationOrder=[]
for(var x=0;x<cols;x++) { for(var y=0;y<rows;y++) { creationOrder.push([x,y]) }
}
return creationOrder
}, updateGrid:function(fillarr,queue) { try{ if(!queue) var queue = this.defaultqueue(this.cols.length,this.rows.length)
for( var i=0; i<queue.length;i++) { var x = queue[i][0]
var y = queue[i][1]
this.grid[this.cols[x]][this.rows[y]] = fillarr[0].apply(fillarr[1],[this.grid[this.cols[x]][this.rows[y]],x,y]) }
}catch(e) { }
}, toString: function() { return "o2.mapy.Grid"; }
}); o2.mapy.GridManager = o2.ClassCreate(o2.EventDispatcher,{ _NORTH : 1, _SOUTH : 2, _WEST  : 4, _EAST  : 8, count: 0, active:true, initialize: function() { this.element=document.createElement("div"); this._tilex=null; this._tiley=null; this._minx=0; this._miny=0; }, setInitData:function(vpsize, lnglat, zoom, margin) { this.vpsize = vpsize
this.margin = margin
this.zoom = zoom
var tc = new o2.mapy.TileCoords(this.zoom); var ctile = tc.geoToTile(lnglat.lng, lnglat.lat); var o = [this.vpsize.width/2, this.vpsize.height/2]; var t1 = [o[0]-ctile[1][0], o[1]-ctile[1][1]]; var t2 = [t1[0]+o2.mapy.TileSize,t1[1]+o2.mapy.TileSize]
with( Math ) { var xlc = ceil(max(0,t1[0])/o2.mapy.TileSize)+margin
var xrc = ceil(max(0,this.vpsize.width-t2[0])/o2.mapy.TileSize)+margin
var ytc = ceil(max(0,t1[1])/o2.mapy.TileSize)+margin
var ybc = ceil(max(0,this.vpsize.height-t2[1])/o2.mapy.TileSize)+margin
}
this._minx = Math.round(t1[0]-xlc*o2.mapy.TileSize); this._miny = Math.round(t1[1]-ytc*o2.mapy.TileSize); this._rootx=ctile[0][0]-xlc; this._rooty=ctile[0][1]-ytc; this.numoftiles = [1+xlc+xrc,1+ytc+ybc]
}, load: function(vpsize, lnglat, zoom, margin) { this.trigger({'e':'loading'})
this.tilec = 0
if(!margin) margin = 1
this.setInitData(vpsize, lnglat, zoom, margin)
this.element.style.position = 'absolute'
this.element.style.left=this._minx+'px'
this.element.style.top=this._miny+'px'
var maxdim =0
if(this.numoftiles[0]<this.numoftiles[1]) { maxdim = 1
}
var mindim = (maxdim+1)%2
var dimdiff = Math.floor((this.numoftiles[maxdim]-this.numoftiles[mindim])/2)
var gridsize = this.numoftiles[maxdim]*this.numoftiles[maxdim]
var pos = [Math.floor(this.numoftiles[maxdim]/2),Math.floor(this.numoftiles[maxdim]/2)]
var dir = (this.numoftiles[maxdim]+1)%2
var i = 1
var tmp
var copypos = [pos[0],pos[1]]
copypos[mindim] = copypos[mindim]-dimdiff
var queue = [copypos]
this._grid = []
while(i<gridsize+1) { i++
tmp = this.getNextSpiralCoord(i, dir, pos)
dir = tmp[0]
pos = tmp[1]
copypos = [pos[0],pos[1]]
copypos[mindim] = copypos[mindim]-dimdiff
if(copypos[mindim]>=0&&copypos[mindim]<this.numoftiles[mindim]&&copypos[(mindim+1)%2]<this.numoftiles[(mindim+1)%2]) { queue.push([copypos[0],copypos[1]]) }
}
this.X = Math.floor(this._minx/o2.mapy.TileSize); this.Y = Math.floor(this._miny/o2.mapy.TileSize); this.loadgrid(queue) }, loadgrid:function(queue) { if(!this.grid) { this.tilec = this.numoftiles[0]*this.numoftiles[1]
this.grid = new o2.mapy.Grid(this.numoftiles[0],this.numoftiles[1],[o2.mapy.fun,this],queue)
this.grid.loaded = true
}
else { var size = this.grid.getSize()
var dc = this.numoftiles[0]-size[0]
var dr = this.numoftiles[1]-size[1]
for(var i=0;i<Math.abs(dc);i++) { if(dc<0) { this.grid.popColumn([o2.mapy.funremove,this]) }
else if(dc>0) { this.grid.pushColumn([o2.mapy.funcol,this]) }
}
for(var i=0;i<Math.abs(dr);i++) { if(dr<0) { this.grid.popRow([o2.mapy.funremove,this]) }
else if(dr<0) { this.grid.pushRow([o2.mapy.funrow,this]) }
}
var numoftiles = this.grid.getSize()
this.tilec = numoftiles[0]*numoftiles[1]
this.grid.updateGrid([o2.mapy.funupdate,this],queue) }
}, tileCounter:function(e) { if(e['e']=='start') { }
else { this.tilec--
}
if(this.tilec==0) { this.trigger({'e':'load'}) }
}, getNextSpiralCoord: function(i,dir,prevpos) { var r = Math.floor(Math.sqrt(i-1))
var n = i - r*r
if(((n-2)%r)==0){ dir = (dir+1)%4 }
copypos = [prevpos[0],prevpos[1]]
copypos[dir%2]+= (dir<2)?1:-1
return [dir,copypos]
}, _preload: function(dir) { this.trigger({'e':'preloading'})
if(dir&this._NORTH) { this.grid.transferRow(-1,[o2.mapy.funrowload]) }
if(dir&this._SOUTH) { this.grid.transferRow(1,[o2.mapy.funrowload]) }
if(dir&this._EAST) { this.grid.transferColumn(1,[o2.mapy.funcolload]) }
if(dir&this._WEST) { this.grid.transferColumn(-1,[o2.mapy.funcolload]) }
}, move: function(dx,dy) { this.divmove(dx,dy); this.checkPreload() }, checkPreload:function() { var t = false
var x = Math.floor(this._minx/o2.mapy.TileSize); var y = Math.floor(this._miny/o2.mapy.TileSize); if(Math.abs(this.X-x)>1||Math.abs(this.Y-y)>1)
t=true
if(this.X-x>0) { this.X--; this._preload(this._EAST); }
if(this.X-x<0) { this.X++; this._preload(this._WEST); }
if(this.Y-y>0) { this.Y--; this._preload(this._SOUTH) }
if(this.Y-y<0) { this.Y++; this._preload(this._NORTH) }
if(t){ this.move(0,0) }
}, divmove: function(dx,dy) { this._minx+=dx; this.element.style.left=this._minx+'px'; this._miny+=dy; this.element.style.top=this._miny+'px'; }, getMapDiv:function(){return this.element;}, getMinTile: function() { var cell = this.grid.getCell(0,0)
return [cell.tilex,cell.tiley]
}, getMinTilePosition:function() { try { var cell = this.grid.getCell(0,0)
return [parseInt(cell.element.style.left),parseInt(cell.element.style.top)]
}
catch(e) { }
}, getMaxTile: function() { var ind  = this.grid.getSize()
var cell = this.grid.getCell(ind[0]-1,ind[1]-1)
return [cell.tilex,cell.tiley]
}, resize:function(vpsize) { var dx = Math.ceil((vpsize.width-this.vpsize.width)/2)
var dy = Math.ceil((vpsize.height-this.vpsize.height)/2)
this.divmove(dx,dy)
var Xch = Math.floor((this._minx)/o2.mapy.TileSize)
var Ych = Math.floor((this._miny)/o2.mapy.TileSize)
this.vpsize = vpsize
if(Xch>this.X) { var addcountc = Math.abs(Xch-this.X)
for(var j=0;j<addcountc;j++) { this.grid.pushColumn([o2.mapy.funcol,this])
this.grid.unshiftColumn([o2.mapy.funcol,this]) }
}
if(Xch<this.X) { var remcountc = Math.abs(Xch-this.X)
for(var j=0;j<remcountc;j++) { this.grid.popColumn([o2.mapy.funremove,this])
this.grid.shiftColumn([o2.mapy.funremove,this]) }
}
if(Ych>this.Y) { var addcountr = Math.abs(Ych-this.Y)
for(var j=0;j<addcountr;j++) { this.grid.pushRow([o2.mapy.funrow,this])
this.grid.unshiftRow([o2.mapy.funrow,this]) }
}
if(Ych<this.Y) { var remcountr = Math.abs(Ych-this.Y)
for(var j=0;j<remcountr;j++) { this.grid.popRow([o2.mapy.funremove,this])
this.grid.shiftRow([o2.mapy.funremove,this]) }
}
this.Y=Ych
this.X=Xch
}, toString: function() { return "o2.mapy.GridManager"; }
}); o2.mapy.funzoom = function(a,x,y) { a.resize(this.dx*x,this.dy*y,this.size)
return a
}
o2.mapy.fun = function(x,y){ var a = new o2.mapy.Tile(this.zoom,this._rootx,this._rooty,x,y)
a.bindAsEventListener(this,'load',this.tileCounter)
a.bindAsEventListener(this,'start',this.tileCounter)
a.initLoad()
this.element.appendChild(a.element)
return a
}
o2.mapy.funupdate = function(a,x,y){ if(!a) { a =new o2.mapy.Tile(this.zoom,this._rootx,this._rooty,x,y) }
a.refresh(this.zoom,this._rootx,this._rooty,x,y)
return a
}
o2.mapy.funrowload = function(row,dy){ for(var i=0;i<row.length;i++) { row[i].changeRow(dy) }
}
o2.mapy.funcolload = function(col,dx){ for(var i=0;i<col.length;i++) { col[i].changeCol(dx) }
}
o2.mapy.funcol=function(col,row){ try{ var tiley = this.grid.getCell(0,0).tiley
var tilex = this.grid.getCell(0,0).tilex
if (col==0) { var cx = tilex-1
}
else { var cx = tilex+col
}
var a = new o2.mapy.Tile(this.zoom,this._rootx,this._rooty,col,row)
a.bindAsEventListener(this,'load',this.tileCounter)
a.bindAsEventListener(this,'start',this.tileCounter)
a.update(cx,tiley+row)
this.element.appendChild(a.element)
return a
}
catch(e){}
}
o2.mapy.funrow=function(col,row){ try{ var tiley = this.grid.getCell(0,0).tiley
var tilex = this.grid.getCell(0,0).tilex
if (row==0) { var ry = tiley-1
}
else { var ry = tiley+row
}
var a = new o2.mapy.Tile(this.zoom,this._rootx,this._rooty,col,row)
a.bindAsEventListener(this,'load',this.tileCounter)
a.bindAsEventListener(this,'start',this.tileCounter)
a.update(tilex+col,ry)
this.element.appendChild(a.element)
return a
}catch(e){}
}
o2.mapy.funremove = function(tiles) { try{ for(var i=0;i<tiles.length;i++) { this.element.removeChild(tiles[i].element)
delete tiles[i].element
delete tiles[i]
}
}catch(e){}
}
o2.mapy.Projection = new function( ){ this.Bc = []
this.Cc = []
this.zc = []
this.Ac = []
c = 256
for (i=0;i<19;i++) { var e = (c/2); this.Bc.push((c/360.0)); this.Cc.push(c/(2 * Math.PI)); this.zc.push([e,e]); this.Ac.push(c); c *= 2
}
this.fromLLtoPixel =function(ll, zoom) { var d = this.zc[zoom]; var e = Math.round(d[0] + ll[0] * this.Bc[zoom]); var f = this.minmax(Math.sin((Math.PI/180) * ll[1]), -0.9999, 0.9999); var g = Math.round(d[1] + 0.5*Math.log((1+f)/(1-f))*-this.Cc[zoom]); return new Array(e, g); }; this.fromPixelToLL=function(px,zoom) { var e = this.zc[zoom]; var f = ((px[0] - e[0])/this.Bc[zoom]); var g = ((px[1] - e[1])/-this.Cc[zoom]); var h = (180/Math.PI) * ( 2 * Math.atan(Math.exp(g)) - 0.5 * Math.PI); return new Array(f, h); }; this.minmax = function(a,b,c) { var a = Math.max(a,b); var a = Math.min(a,c); return a; }; }
o2.mapy.TileCoords=function(zoom) { this.TileSize = o2.mapy.TileSize
this.ll0 = [this.TheBBox[0], this.TheBBox[3]]; this.ll1 = [this.TheBBox[2], this.TheBBox[1]]; this.zoom = zoom; this.px0 = o2.mapy.Projection.fromLLtoPixel(this.ll0, zoom); this.px1 = o2.mapy.Projection.fromLLtoPixel(this.ll1, zoom); this.xTileRangeStart = parseInt(this.px0[0] / this.TileSize); this.yTileRangeStart = parseInt(this.px0[1] / this.TileSize); }; o2.mapy.TileCoords.prototype.TheBBox=[8.36484367936216, 45.7720975335854,30.2847663044987, 56.3083266193716]; o2.mapy.TileCoords.prototype.tileToGeo=function(tx, ty, dx, dy) { tx += this.xTileRangeStart; ty += this.yTileRangeStart; if(!dx)
dx=0
if(!dy)
dy=0
px0 = [tx * this.TileSize+dx, (ty + 1) * this.TileSize+dy]; px1 = [(tx + 1) * this.TileSize+dx, ty * this.TileSize+dy]; g0 = o2.mapy.Projection.fromPixelToLL(px0, this.zoom); g1 = o2.mapy.Projection.fromPixelToLL(px1, this.zoom); return new Array(g0, g1); }; o2.mapy.TileCoords.prototype.geoToTile=function(x, y) { l= o2.mapy.Projection.fromLLtoPixel([x, y], this.zoom); px = l[0]; py = l[1]; tx = parseInt(px / this.TileSize); ty = parseInt(py / this.TileSize); dx = px % this.TileSize; dy = py % this.TileSize; tx -= this.xTileRangeStart; ty -= this.yTileRangeStart; return [[tx, ty], [dx, dy]]; }; o2.mapy.TileCoords.prototype.toString=function() { return "o2.mapy.TileCoords"; }; o2.mapy.BoundingBox = o2.ClassCreate({ lls: null, initialize: function(ll1, ll2) { this.lls = new Array(); if(arguments.length==1) { if(ll1 instanceof Array) { this.getExtent(ll1) } else if(typeof(ll1)=="string") { var a= ll1.split(" "); this.lls[0]=new o2.mapy.LngLat(parseFloat(a[0]),parseFloat(a[1])); this.lls[1]=new o2.mapy.LngLat(parseFloat(a[2]),parseFloat(a[3])); }
} else if(arguments.length==2) { if(ll1!=null)
this.lls[0]=ll1; if(ll2!=null)
this.lls[1]=ll2; }
}, getExtent:function(arr) { if(arr.length==0 ||!arr|| ( (arr.length==1 ) && !( arr[0] instanceof o2.mapy.BoundingBox ) ) ) { throw new Error("Cannot initiate BoundingBox without coords") }
else { var NW = [180, -90]; var SE = [-180, 90]; for(var i=0; i<arr.length; i++) { if(arr[i] instanceof o2.mapy.BoundingBox) { NW[0]=Math.min(NW[0], arr[i].getNorthWest().lng); NW[1]=Math.max(NW[1], arr[i].getNorthWest().lat); SE[0]=Math.max(SE[0], arr[i].getSouthEast().lng); SE[1]=Math.min(SE[1], arr[i].getSouthEast().lat); continue; }
else { NW[0]=Math.min(NW[0], arr[i].lng); NW[1]=Math.max(NW[1], arr[i].lat); SE[0]=Math.max(SE[0], arr[i].lng); SE[1]=Math.min(SE[1], arr[i].lat); }
}
this.lls[0]=new o2.mapy.LngLat(NW[0], NW[1]); this.lls[1]=new o2.mapy.LngLat(SE[0], SE[1]); }
}, getLngLats: function() { return this.lls; }, toString: function() { return this.lls.join(','); }, getMapDivPoint:function(map) { return [this.getNorthWest().getMapDivPoint(map), this.getSouthEast().getMapDivPoint(map)]; }, getSouthWest:function() { var lat = Math.min(this.lls[0].lat, this.lls[1].lat); var lng = Math.min(this.lls[0].lng, this.lls[1].lng); return new o2.mapy.LngLat(lng, lat); }, getNorthEast: function() { var lat = Math.max(this.lls[0].lat,this.lls[1].lat); var lng = Math.max(this.lls[0].lng,this.lls[1].lng); return new o2.mapy.LngLat(lng, lat); }, getNorthWest: function() { return new o2.mapy.LngLat(Math.min(this.lls[0].lng, this.lls[1].lng), Math.max(this.lls[0].lat, this.lls[1].lat)); }, getSouthEast: function() { return new o2.mapy.LngLat(Math.max(this.lls[0].lng, this.lls[1].lng), Math.min(this.lls[0].lat, this.lls[1].lat)); }, containsBounds:function(bb) { var la1 = this.getSouthEast(); var lb1 = bb.getSouthEast(); var la2 = this.getNorthWest(); var lb2 = bb.getNorthWest(); if(la1.lng>=lb1.lng&&la1.lat<=lb1.lat&&la2.lat>=lb2.lat&&la2.lng<=lb2.lng) { return true; }
return false; }, getPixelWidth:function(zoom) { return o2.mapy.LngLat.getPixelDistance(this.getNorthEast(),this.getSouthWest(),zoom).dx; }, getPixelHeight:function(zoom) { return o2.mapy.LngLat.getPixelDistance(this.getNorthEast(),this.getSouthWest(),zoom).dy; }, getBestZoom:function(map) { var curzoom=map.getZoom(); var sl1 = this.getNorthEast().getMapDivPoint(map)
var sl2 = this.getSouthWest().getMapDivPoint(map)
var sw = parseFloat(Math.abs(sl1.x-sl2.x)/map.vpsize.width)
var sh = parseFloat(Math.abs(sl1.y-sl2.y)/map.vpsize.height)
var a = Math.max(sw,sh)||1
if(a>1){ curzoom--
while(a/2>1) { a /=2
curzoom--
}
}else { while(a*2<1.01) { a *=2
curzoom++
}
}
return Math.min(Math.max(curzoom,7),18) }, getCenter:function() { return new o2.mapy.LngLat((this.lls[0].lng+this.lls[1].lng)/2, (this.lls[0].lat+this.lls[1].lat)/2); }
}); o2.mapy.BoundingBoxLayer = o2.ClassCreate(o2.mapy.MapMovableLayer, { group: "BoundingBoxLayer", defaultOptions: { clickable: false, draggable: false, style: {}, panmapstrategy: { type: "none"
}
}, initialize: function($super, bbox, options) { this.BoundingBox=bbox; $super(new o2.mapy.LngLat(21, 52), "", options); }, refresh:function() { var state=this.map.getState(); var points=this.BoundingBox.getMapDivPoint(this.map); var minx, miny, maxx, maxy; var sw = points[0]; var ne = points[1]; var minx = Math.min(sw.x,ne.x); var maxx = Math.max(sw.x,ne.x); var miny = Math.min(sw.y,ne.y); var maxy = Math.max(sw.y,ne.y); var width=Math.abs(maxx-minx); var height=Math.abs(maxy-miny); if(width<30) { width+=50; minx-=25; } else  { width+=20; minx-=10; }
if(height<30) { height+=50; miny-=25; } else { height+=20; miny-=10; }
o2.ObjectExtend(
this.element.style, { width: width + "px", height: height + "px", top: miny + "px", left: minx + "px"
}
); }, toString: function() { return "o2.mapy.BoundingBoxLayer"; }
}); o2.mapy.Map = o2.ClassCreate(o2.EventDispatcher, { _draggable: true, panObj : false, getSize: function(slot) { var width, height; if(slot.parentNode && slot.parentNode.nodeType==1) { var slotSize=o2.ElementSize(slot); width=slotSize.width-(slot.clientLeft || 0)*2; height=slotSize.height-(slot.clientTop || 0)*2; } else { width=parseInt(slot.style.width); height=parseInt(slot.style.height); }
if(!width || !height)
throw new Error("Wymiary mapy nie zostały znalezione."); this.vpsize = new o2.mapy.Size(width,height); }, initialize:function(slot) { if(typeof(slot)=="string")
slot=document.getElementById(slot); this.getSize(slot); this.slot = slot; this.createStaticLays(); this.mapdiv = new o2.mapy.GridManager(); this.createMovableLays(); this.dshArray=new Array(); this.slot.appendChild(this.mapdiv.getMapDiv()); this.appendNonClickableSlot(); this.appendNonClickableMovableLay(); this.createTransparentDiv(); this.appendClickableMovableLay(); this.appendClickableSlot(); }, loadmap:function(){ this.trigger({e: 'load'}) }, resize: function(width, height) { o2.ObjectExtend(this.transp.style, {width: width + "px", height: height + "px"}); this.vpsize = new o2.mapy.Size(width,height)
this.mapdiv.resize(this.vpsize)
this.trigger({e:'resize'})
this.clickablestaticlay.refresh(); this.nonclickablestaticlay.refresh(); }, createStaticLays:function() { if(!this.slot.style.left || !this.slot.style.top) { o2.ObjectExtend(this.slot.style, {position: "relative", left: "0px", top: "0px", overflow: "hidden", background: "#fff"}); } else { o2.ObjectExtend(this.slot.style, {position: "relative", overflow: "hidden", background: "#fff"}); }
this.clickablestaticlay = new o2.mapy.LaysContainer(new o2.mapy.ResizeRefreshStrategy(),300); this.nonclickablestaticlay = new o2.mapy.LaysContainer(new o2.mapy.ResizeRefreshStrategy(),190); this.bindAsEventListener(this.clickablestaticlay,'centerset',this.clickablestaticlay.refresh); this.bindAsEventListener(this.nonclickablestaticlay,'centerset',this.nonclickablestaticlay.refresh); this.bindAsEventListener(this.clickablestaticlay,'resize',this.clickablestaticlay.refresh); this.bindAsEventListener(this.nonclickablestaticlay,'resize',this.nonclickablestaticlay.refresh); }, appendClickableSlot: function() { this.slot.appendChild(this.clickablestaticlay._element); }, appendNonClickableSlot: function() { this.slot.appendChild(this.nonclickablestaticlay._element); }, createMovableLays: function() { this.clickmovable=new o2.mapy.LaysContainer(new o2.mapy.ZoomRefreshStrategy(this.mapdiv),250); this.nonclickmovable=new o2.mapy.LaysContainer(new o2.mapy.ZoomRefreshStrategy(this.mapdiv),150); this.clickmovable.setToBeginning()
this.nonclickmovable.setToBeginning()
this.bindAsEventListener(this.clickmovable,'centerset',this.clickmovable.refresh); this.bindAsEventListener(this.nonclickmovable,'centerset',this.nonclickmovable.refresh); this.bindAsEventListener(this.clickmovable, 'resize', this.clickmovable.refresh); this.bindAsEventListener(this.nonclickmovable, 'resize', this.nonclickmovable.refresh); }, appendClickableMovableLay: function() { this.slot.appendChild(this.clickmovable._element); }, appendNonClickableMovableLay: function() { this.slot.appendChild(this.nonclickmovable._element); }, createTransparentDiv:function() { this.transp=document.createElement("div"); var h = {position: "absolute", overflow: "hidden", top: "0px", left: "0px", width: this.vpsize.width + "px", height: this.vpsize.height + "px", background: "url(http://mapapi.o2.pl/api/images/transparent.gif?rev=3571)"
}; o2.ObjectExtend(this.transp.style, h); this.transp.style.zIndex = 200
this.slot.appendChild(this.transp); if(this._draggable)
this.changeDsh(o2.mapy.DragScrollableStandard, this.transp, null); else
this.changeDsh(o2.mapy.DragScrollableFreez, this.transp, null); }, setCenter: function(lnglat,zoom) { this.center = lnglat
this.zoom   = parseInt(zoom)
this.mapdiv.load(this.vpsize,lnglat,zoom)
this.trigger({e: 'centerset', zoom: zoom, center: lnglat}); }, panAndScaleToBBox:function(bbox) { this.setCenter(bbox.getCenter(),bbox.getBestZoom(this)) }, changeDsh: function(dshClass, element, context) { if(this.dshArray.length==1)
this.dshArray[0].destroy(); this.dshArray[0]=new dshClass(element, context); this.dshArray[0].map=this; if(this.dshArray.length==1)
this.dshArray[0].rebuild(); }, enableDragging: function() { this.changeDsh(o2.mapy.DragScrollableStandard, this.transp, null); }, disableDragging: function() { this.changeDsh(o2.mapy.DragScrollableFreez, this.transp, null); }, loadDsh: function(dsh) { this.dshArray[this.dshArray.length-1].destroy(); dsh.map=this; dsh.rebuild(); this.dshArray.push(dsh); }, unLoadDsh: function(dsh) { var len=this.dshArray.length-1; if(this.dshArray[len]===dsh) { this.dshArray[len].destroy(); delete this.dshArray[len]; this.dshArray=o2.ArrayCompact(this.dshArray); this.dshArray[len-1].rebuild(); return ; }
while(len--) { if(this.dshArray[len]===dsh) { delete this.dshArray[len]; this.dshArray=o2.ArrayCompact(this.dshArray); break; }
}
}, addOverlay:function() { for(var i=0, len=arguments.length; i<len; i++) { if(arguments[i] instanceof o2.mapy.Layer) { arguments[i].setMap(this); arguments[i].draw(); }
else
throw Error("Próbujesz dodać do mapy nieosadzalny obiekt: " + arguments[i].toString()); }
}, getContainer: function() { return this.slot; }, getViewPortBB: function(padding) { if (padding == undefined) { var padding = new o2.mapy.Size(0,0); }
return new o2.mapy.BoundingBox((new o2.mapy.ViewPortPoint(padding.width, padding.height)).getLngLat(this), (new o2.mapy.ViewPortPoint(this.vpsize.width-padding.width, this.vpsize.height-padding.height)).getLngLat(this)); }, getCenter:function() { return (new o2.mapy.ViewPortPoint(this.vpsize.width/2,this.vpsize.height/2)).getLngLat(this); }, getTechState:function() { return { zoom: this.mapdiv.zoom, rootx: this.mapdiv._rootx, rooty: this.mapdiv._rooty
}
}, getZoom: function() { return this.mapdiv.zoom; }, move: function(dx, dy) { this.mapdiv.move(dx, dy); this.clickmovable.setToBeginning(); this.nonclickmovable.setToBeginning(); }, zoomin:function(center) { if(this.mapdiv.zoom>17)
return
if(!center)
var center = this.getCenter(); if(!(center instanceof o2.mapy.LngLat))
var center = (new o2.mapy.ViewPortPoint(center[0],center[1]).getLngLat(this))
var zoom = this.zoom+1; try { this.setCenter(center,zoom); } catch(e) {}
}, zoomout:function(center) { try{ if(this.mapdiv.zoom<7) return
if(!center) { var center = this.getCenter() }
if(!(center instanceof o2.mapy.LngLat)) { var center = (new o2.mapy.ViewPortPoint(center[0],center[1]).getLngLat(this)) }
var zoom = this.zoom-1
this.setCenter(center,zoom) }catch(e){}
}, pan: function(direction, px) { if(px>Math.max(this.vpsize.width,this.vpsize.height)) { this.setCenter((new o2.mapy.ViewPortPoint(px+this.vpsize.width/2,px+this.vpsize.height/2)).getLngLat(this),this.zoom) }
else{ if(!this.panObj) { this.panObj = new o2.mapy.PanTo(this); }; this.panObj.start(direction[0]*px, direction[1]*px); }
}, panTo: function(lnglat, x, y) { try{ if(!x)
x=0; if(!y)
y=0; var start = new o2.mapy.MapDivPoint(this.vpsize.width/2-this.mapdiv._minx, this.vpsize.height/2-this.mapdiv._miny); var stop = lnglat.getMapDivPoint(this); var vector = new o2.mapy.MapDivPoint(start.x-stop.x+x, start.y-stop.y+y)
if(vector.x>this.vpsize.width||vector.y>this.vpsize.height) { var ll = (new o2.mapy.MapDivPoint(stop.x-x,stop.y-y)).getLngLat(this)
this.setCenter(ll,this.mapdiv.zoom)
return
}
if(!this.panObj) { this.panObj = new o2.mapy.PanTo(this); }
this.panObj.start(vector.x, vector.y); }catch(e){}
}, getMapdivBB: function() { var tc=new o2.mapy.TileCoords(this.mapdiv.zoom); var tiles = [this.mapdiv.getMaxTile(),this.mapdiv.getMinTile()]; var p = [tc.tileToGeo(tiles[0][0],tiles[0][1]), tc.tileToGeo(tiles[1][0],tiles[1][1])]; var latlan1 = [p[0][1][0],p[0][0][1]]; var latlan2 = [p[1][0][0],p[1][1][1]]; return new o2.mapy.BoundingBox(new o2.mapy.LngLat(latlan1[0],latlan1[1]),new o2.mapy.LngLat(latlan2[0],latlan2[1])); }, getObjectsByGroup:function() { var result=new Array(); var c1=this.clickmovable.getObjectsByGroup.apply(this.clickmovable, arguments); for(var i=0, len1=c1.length; i<len1; i++)
result.push(c1[i]); var c2=this.nonclickmovable.getObjectsByGroup.apply(this.nonclickmovable, arguments); for(var j=0, len2=c2.length; j<len2; j++)
result.push(c2[j]); var c3=this.clickablestaticlay.getObjectsByGroup.apply(this.clickablestaticlay, arguments); for(var k=0, len3=c3.length; k<len3; k++)
result.push(c3[k]); var c4=this.nonclickablestaticlay.getObjectsByGroup.apply(this.nonclickablestaticlay, arguments); for(var l=0, len4=c4.length; l<len4; l++)
result.push(c4[l]); return result; }, clearGroup: function() { this.clickmovable.clearGroup.apply(this.clickmovable, arguments); this.nonclickmovable.clearGroup.apply(this.nonclickmovable, arguments); this.clickablestaticlay.clearGroup.apply(this.clickablestaticlay, arguments); this.nonclickablestaticlay.clearGroup.apply(this.nonclickablestaticlay, arguments); }, getState:function() { return {center: this.getCenter(), zoom: this.mapdiv.zoom}; }, getViewPortWidth: function() { return this.vpsize.width; }, getViewPortHeight: function() { return this.vpsize.height; }, getByClass:function() { var result=new Array(); var c1=this.clickmovable.getByClass.apply(this.clickmovable, arguments); for(var i=0, len1=c1.length; i<len1; i++)
result.push(c1[i]); var c2=this.nonclickmovable.getByClass.apply(this.nonclickmovable, arguments); for(var j=0, len2=c2.length; j<len2; j++)
result.push(c2[j]); var c3=this.clickablestaticlay.getByClass.apply(this.clickablestaticlay, arguments); for(var k=0, len3=c3.length; k<len3; k++)
result.push(c3[k]); var c4=this.nonclickablestaticlay.getByClass.apply(this.nonclickablestaticlay, arguments); for(var l=0, len4=c4.length; l<len4; l++)
result.push(c4[l])
return result; }, clearByClass:function() { var lays=this.getByClass.apply(this, arguments); for(var i=0, len=lays.length; i<len; i++)
lays[i].clear(); }, hideByClass:function() { var lays=this.getByClass.apply(this, arguments); for(var i=0, len=lays.length; i<len; i++)
lays[i].element.style.display="none"; }, showByClass:function(classes, exclude) { var lays=this.getByClass.apply(this, classes); for(var i=0, len=lays.length; i<len; i++)
lays[i].element.style.display="block"; }, centerOrReset:function() { if (this.getObjectsByGroup('Marker').length > 0) { tmp = this.getObjectsByGroup('Marker')[1]; this.setCenter(tmp.options.point, this.mapdiv.zoom); }
else { this.setCenter(new o2.mapy.LngLat(19.50625,52.02510758314961),7); }
}, toString: function() { return "o2.mapy.Map"; }
}); o2.mapy.PanTo=function(obj) { this.obj=obj; }, o2.mapy.PanTo.prototype.start=function(dx, dy) { this.dy0 = dy; this.dx0 = dx; this.dx    = dx; this.dy    = dy; this.prox  = 20; this.proy  = Math.abs(dy/dx)*this.prox; this.move(); }; o2.mapy.PanTo.prototype.move=function() { var dx = parseInt(Math.min(Math.abs(this.dx/Math.sqrt(Math.abs(this.dx))),this.prox)*this.signum(this.dx))||0
var dy = parseInt(Math.min(Math.abs(this.dy/Math.sqrt(Math.abs(this.dy))),this.proy)*this.signum(this.dy))||0
if(Math.abs(dx)+Math.abs(dy)>=1) { this.obj.move(dx,dy); this.dx-=dx; this.dy-=dy; window.setTimeout(o2.FunctionBind(this.move, this), 1); } else { this.obj.move(dx, dy); this.obj.trigger({	e: 'panend', vector: new Array(this.dx0, this.dy0)}); }
}; o2.mapy.PanTo.prototype.signum=function(number) { return number/Math.abs(number); }; o2.mapy.PanTo.prototype.toString=function() { return "o2.mapy.PanTo"; }; o2.mapy.Unload = function() { }; o2.mapy.DragScrollableLayerMove=o2.ClassCreate(o2.mapy.DragScrollableAbstract, { defaultCursor: "url(http://mapapi.o2.pl/api/images/cursors/closedhandmarker.cur?rev=3571), move", rebuild: function() { this.eventMouseMove=o2.FunctionBindAsEventListener(this.funcMouseMove, this.context, o2.FunctionBind(this.arbitraryMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); this.eventMouseUp=o2.FunctionBindAsEventListener(this.funcMouseUp, this.context, o2.FunctionBind(this.arbitraryMouseData, this.map), o2.FunctionBind(this.triggerArtEvent, this.map)); o2.Event.observe(this.element, 'mousemove', this.eventMouseMove); o2.Event.observe(this.element, 'mouseup', this.eventMouseUp); this.context.trigger({e: "dragstart"}); }, destroy: function() { o2.Event.stopObserving(this.element, 'mousemove', this.eventMouseMove); o2.Event.stopObserving(this.element, 'mouseup', this.eventMouseUp); this.context.trigger({ e: "dragend", g: this.context.point
}); }, funcMouseMove: function(event, mouseData, eventTrigger) { var tmp = o2.mapy.MapDivPoint.sum(mouseData(event).mapdiv_point, this.fix); this.point=tmp.getLngLat(this.map); this.refresh(); }, funcMouseUp: function(event, mouseData, eventTrigger) { this.element.style.cursor="url(http://mapapi.o2.pl/api/images/cursors/openhandmarker.cur?rev=3571), default"; this.panMapFunctions[this.options.panmapstrategy.type].call(this); this.map.unLoadDsh(this.dsh); }, toString: function() { return "o2.mapy.DragScrollableLayerMove"; }
}); o2.mapy.DragScrollableLayerHold=o2.ClassCreate(o2.mapy.DragScrollableAbstract, { destroy: function($super) { $super(); this.context.trigger({e: "click"}); }, funcMouseUp: function(event, mouseData, eventTrigger) { this.map.unLoadDsh(this.dsh); }, toString: function() { return "o2.mapy.DragScrollableLayerHold"; }
}); o2.mapy.Marker = o2.ClassCreate(o2.mapy.MapMovableLayer, { group:"Marker", defaultOptions: { clickable: true, draggable: false, size: new o2.mapy.Size(37,57), displacement: "19, 0s", style: { backgroundImage: "url(http://mapapi.o2.pl/api/images/marker.png?rev=3571)"
}, panmapstrategy: { type: "none"
}
}, initialize:function($super, point, options) { $super(point, '', options); if(this.options.clickable && this.options.content.layer) { this.bindAsEventListener(this, "click", this.contentFunctions.onClick); this.bindAsEventListener(this, "dragstart", this.clearContent); this.bindAsEventListener(
this.options.content.layer, "dragend", function(event) { this.point=event.g; this.draw(); }
); }
if(this.options.shadow) { this.options.shadow.clickable=false; this.shadow=new o2.mapy.MapMovableLayer(point, '', this.options.shadow); this.shadow.group="Marker"; }
}, setMap: function($super, map) { $super(map); if(this.shadow)
this.shadow.setMap(map); if(this.options.content.layer)
this.options.content.layer.setMap(map); }, draw:function($super) { $super(); if(this.shadow)
this.shadow.draw(); if(this.options.content.draw)
this.options.content.layer.draw(); }, clear:function($super) { this.clearContent(); if(this.shadow)
this.shadow.clear(); $super(); }, refresh:function($super) { $super(); if(this.shadow) { this.shadow.point=this.point; this.shadow.refresh(); }
}, clearContent: function() { if(this.options.content.layer && this.options.content.layer.isDrawn)
this.options.content.layer.clear(); }, toString: function() { return "o2.mapy.Marker"; }, contentFunctions: { onClick: function(event) { if(!this.options.content.layer)
return; if(this.options.content.layer.isDrawn)
this.options.content.layer.clear(); else
this.options.content.layer.draw(); }
}
}); o2.mapy.Window=o2.ClassCreate(o2.mapy.MapMovableLayer, { group:"Window", defaultOptions: { clickable: true, draggable: false, displacement: "31, 29s", style: {}, panmapstrategy: { type: "none"
}, shadow: { displacement: "31, 29", size: new o2.mapy.Size("auto", 30), style: { backgroundImage: "url(http://mapapi.o2.pl/api/images/dymek/dymek_dol_zolty.png?rev=3571)"
}
}
}, defaultControllers: function() { return new Array( { path: "div.t_note_closer", event: "click", func: o2.FunctionBindAsEventListener(this.clear, this) }
); }, template: new o2.Template(
'<div style="margin: 0px; padding: 0px; border: solid #fff; border-width: 1px 1px 0px 1px">' +
'<div style="margin: 0px; padding: 10px; border: solid #000; border-width: 1px 1px 0px 1px; background-color: #fff;">' +
'	<div class="t_note_closer" style="font-size: 0px; width: 12px; height: 12px; background-image: url(http://mapapi.o2.pl/api/images/dymek_zamykanie.png?rev=3571); position: absolute; top: 12px; right: 12px; cursor: pointer"></div>' +
'	#{content}' +
'</div>' +
'</div>'
), initialize: function($super, point, content, options) { if(content!=null) { if(!options)
options=new Object(); if(!options.substitute)
options.substitute=new Object(); options.substitute.content=content.toString(); }
$super(point, '', options); this.options.shadow.clickable=false; this.shadow = new o2.mapy.MapMovableLayer(this.point, "", this.options.shadow); }, setMap: function($super, map) { $super(map); this.shadow.setMap(map); }, draw:function($super) { $super(); this.shadow.options.size=new o2.mapy.Size(this.elementSize().width, this.shadow.options.size.height); this.shadow.setElement(this.shadow.element); this.shadow.draw(); }, clear:function($super) { this.shadow.clear(); $super(); }, refresh:function($super) { $super(); this.shadow.point=this.point; this.shadow.refresh(); }, toString: function() { return "o2.mapy.Window"; }
}); o2.ImageCache("http://mapapi.o2.pl/api/images/dymek_zamykanie.png?rev=3571"); o2.ImageCache("http://mapapi.o2.pl/api/images/dymek/dymek_dol_zolty.png?rev=3571"); o2.mapy.MapMessage = o2.ClassCreate(o2.mapy.MapStaticLayer, { group:"MapMessage", defaultOptions: { positioner: new o2.mapy.CenterMiddlePositionStrategy(), style: { border: 'solid white 1px', background: '#fff'
}, clickable: true
}, template: new o2.Template(
'<div style="border: solid black 1px">' +
'	#{msg}' +
'	<div style="text-align:center;margin:20px 0px 20px 0px">' +
'		<div style="width:16px;height:16px;background:url(http://mapapi.o2.pl/api/images/wait.gif?rev=3571) no-repeat;margin:0px auto"></div>' +
'	</div>' +
'</div>'
), initialize:function($super, msg, options) { if(msg!=null) { if(!options)
options=new Object(); if(!options.substitute)
options.substitute=new Object(); options.substitute.msg=msg.toString(); }
$super('', options); }, setMap: function($super, map) { $super(map); this.dsh=new o2.mapy.DragScrollableAbstract(map.transp, null); }, draw: function($super) { $super(); this.map.loadDsh(this.dsh); }, clear: function($super) { this.map.unLoadDsh(this.dsh); $super(); }, toString: function() { return "o2.mapy.MapMessage"; }
}); o2.ImageCache("http://mapapi.o2.pl/api/images/wait.gif?rev=3571"); o2.mapy.MapConfirm = o2.ClassCreate(o2.mapy.MapStaticLayer, { group:"MapConfirm", defaultOptions: { positioner: new o2.mapy.CenterMiddlePositionStrategy(), style: { border: 'solid white 1px', background: '#fff'
}, clickable: true
}, defaultControllers: function() { return new Array( { path: "div.false_button", event: "click", func: o2.FunctionBindAsEventListener(this.decline, this) }, { path: "div.close", event: "click", func: o2.FunctionBindAsEventListener(this.decline, this) }, { path: "div.true_button", event: "click", func: o2.FunctionBindAsEventListener(this.confirm, this) }
); }, template: new o2.Template(
'<div style="border: solid black 1px; float:left">' +
'	<div class="close" style="position:absolute;top:7px;right:7px;width:20px;height:20px;background:url(http://mapapi.o2.pl/api/images/dymek_zamykanie.png?rev=3571) no-repeat"></div>' +
'	#{msg}' +
'	<table style="width:100%;margin:20px 0px 20px 0px"><tr><td></td>' +
'		<td style="width:67px;height:27px">' +
'			<div class="false_button" style="width:67px;height:27px;background:url(http://mapapi.o2.pl/api/images/anuluj.png?rev=3571) no-repeat"></div>' +
'		</td>' +
'		<td style="width:73px;height:27px">' +
'			<div class="true_button" style="width:73px;height:27px;background:url(http://mapapi.o2.pl/api/images/dalej.png?rev=3571) no-repeat"></div>' +
'		</td>' +
'	<td></td></tr></table>' +
'</div>'
), initialize:function($super, msg, onConfirm, onDecline, options) { if(msg!=null) { if(!options)
options=new Object(); if(!options.substitute)
options.substitute=new Object(); options.substitute.msg=msg.toString(); }
this.confirmFunc=onConfirm; this.declineFunc=onDecline; $super('', options); }, confirm:function() { this.clear(); this.confirmFunc(); }, decline:function() { this.clear(); this.declineFunc(); }, toString: function() { return "o2.mapy.MapConfirm"; }
}); o2.ImageCache("http://mapapi.o2.pl/api/images/dymek_zamykanie.png?rev=3571"); o2.ImageCache("http://mapapi.o2.pl/api/images/anuluj.png?rev=3571"); o2.ImageCache("http://mapapi.o2.pl/api/images/dalej.png?rev=3571"); o2.mapy.ZoomLayer = o2.ClassCreate(o2.mapy.MapStaticLayer, { group: "ZoomLayer", skale:{6:200,7:100,8:50,9:25,10:10,11:5,12:2,13:1,14:1,15:0.5,16:0.2,17:0.1,18:0.05}, defaultOptions: { style: { background: 'none', textAlign: "center", fontSize: "9px"
}, clickable: false, size: new o2.mapy.Size(190,37), positioner: new o2.mapy.LeftBottomPositionStrategy() }, initialize: function($super, options) { this.div = document.createElement('div'); this.div.style.cssText='padding-left:8px;'; this.div.innerHTML='<img src="http://mapapi.o2.pl/api/images/skala_left.png?rev=3571" /><img src="http://mapapi.o2.pl/api/images/skala_center.png?rev=3571" class="skala_center" /><img src="http://mapapi.o2.pl/api/images/skala_right.png?rev=3571" /><br /><span class="skala_info"></span>'; $super(this.div, options); }, draw:function($super) { $super(); map.bindAsEventListener(this,'moveend',this.showScale); map.bindAsEventListener(this,'centerset',this.showScale); this.showScale(); }, showScale:function() { var x = this.getScale(); o2.ObjectExtend((o2.ElementSelect(this.element, "img", 'skala_center'))[0].style, {width: x[1]+'px', height: '4px'}); this.skalapx=x[1]; if (x[0] >= 1) { var text = x[0]+' km'; }
else { var text = (x[0]*1000)+' m'; }
(o2.ElementSelect(this.element, "span", 'skala_info'))[0].innerHTML=text; }, getScale:function() { var tmp = new o2.mapy.ViewPortPoint(this.map.vpsize.width/2, this.map.vpsize.height/2); var p1 = tmp.getLngLat(this.map); tmp.x=(tmp.x+100); var p2 = tmp.getLngLat(this.map); var realdistance = o2.mapy.LngLat.getDistance(p1,p2); var dist = this.skale[this.map.zoom]; var px = Math.round(dist*100/realdistance); return [dist,px]; }, toString: function() { return "o2.mapy.ZoomLayer"; }
}); o2.mapy.Button = o2.ClassCreate(o2.mapy.MapStaticLayer, { defaultOptions: { positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(0, 0)), size: new o2.mapy.Size(100, 100), clickable: true, softactivation: "standard", style: { overflow: "hidden"
}, onimgpos: "0px 0px", offimgpos: "0px 0px", drawtest: function() { return false; }
}, defaultControllers: function() { return new Array( { event: "click", func: o2.FunctionBindAsEventListener(this.changeState, this) }
); }, initialize: function($super, options) { this.state="off"; var content = '<div><div style="width: '+this.imageSize.getWidthString()+'; height: '+this.imageSize.getHeightString()+';'+o2.AlphaImage(this.image)+'"> </div></div>'; $super(content, options); if(!this.options.eventword)
throw Error("Brakuje opcji eventword - nazwy dla zdarzenia obsługiwanego przez przycisk."); var margins = this.options.offimgpos.split(' '); this.element.childNodes[0].style.marginLeft = margins[0]; this.element.childNodes[0].style.marginTop = margins[1]; this.eventSpace.bindAsEventListener(this, this.options.eventword + "mode", this.softactivation[this.options.softactivation].activate); this.eventSpace.bindAsEventListener(this, "end" + this.options.eventword + "mode", this.softactivation[this.options.softactivation].deactivate); this.eventSpace.bindAsEventListener(this, "switchto" + this.options.eventword + "mode", this.activate); this.eventSpace.bindAsEventListener(this, "endswitchto" + this.options.eventword + "mode", this.deactivate); if(this.options.tooltipmsg && typeof(this.toolTipFactory)=="function")
this.toolTip=this.toolTipFactory(this.options.tooltipmsg); }, setMap:function($super, map) { $super(map); if(this.options.onactivationreq)
this.options.onactivationreq.setMap(map); if(this.options.onadectivationreq)
this.options.onadectivationreq.setMap(map); }, eventSpace: null, image: null, imageSize: null, toolTipFactory: null, changeState: function() { if(this.state=='off') { this.activate(); } else { this.deactivate(); }
}, _activate: function() { if(this.state!='on') { this.eventSpace.trigger({e: 'endyourmode'}); if(this.on())
this.eventSpace.trigger({e: this.options.eventword + 'mode'}); }
}, _deactivate: function() { if(this.state!='off') { if(this.off())
this.eventSpace.trigger({e: 'end' + this.options.eventword + 'mode'}); }
}, activate: function() { if(this.options.onactivationreq && this.activateCondition()) { this.options.onactivationreq.confirmFunc = o2.FunctionBind(this.activationConfirmHandler, this); this.options.onactivationreq.declineFunc = function(){}; this.options.onactivationreq.draw(); } else
this._activate(); }, deactivate: function() { if(this.options.ondeactivationreq && this.deactivateCondition()) { this.options.ondeactivationreq.confirmFunc = o2.FunctionBind(this.deactivationConfirmHandler, this); this.options.ondeactivationreq.declineFunc = function(){}; this.options.ondeactivationreq.draw(); } else
this._deactivate(); }, on: function() { if(this.options.dshclass) { this.dsh=new (this.options.dshclass)(this.map.transp, null); this.map.loadDsh(this.dsh); }
return true; }, off: function() { if(this.options.dshclass) { this.map.unLoadDsh(this.dsh); }
return true; }, activateCondition: function() { throw new Error("Musisz zdefiniować warunek wyświetlenia potwierdzenia. Funkcja activateCondition Twojego guzika."); }, activationConfirmHandler: function() { this.onActivationConfirm(); this._activate(); }, onActivationConfirm: function() { }, deactivateCondition: function() { throw new Error("Musisz zdefiniować warunek wyświetlenia potwierdzenia. Funkcja deactivateCondition Twojego guzika."); }, deactivationConfirmHandler: function() { this.onDeactivationConfirm(); this._deactivate(); }, onDeactivationConfirm: function() { }, draw: function($super) { $super(); if(this.options.drawtest())
this.eventSpace.trigger({e: this.options.eventword + 'mode'}); }, toString: function() { return "o2.mapy.Button"; }, softactivation: { standard: { activate: function() { var margins = this.options.onimgpos.split(' '); this.element.childNodes[0].style.marginLeft = margins[0]; this.element.childNodes[0].style.marginTop = margins[1]; if(this.toolTip && !this.toolTip.isDrawn)
this.toolTip.draw(); this.state="on"; }, deactivate: function() { var margins = this.options.offimgpos.split(' '); this.element.childNodes[0].style.marginLeft = margins[0]; this.element.childNodes[0].style.marginTop = margins[1]; if(this.toolTip && this.toolTip.isDrawn)
this.toolTip.clear(); this.state="off"; }
}, time: { activate: function() { var margins = this.options.onimgpos.split(' '); this.element.childNodes[0].style.marginLeft = margins[0]; this.element.childNodes[0].style.marginTop = margins[1]; if(this.toolTip && !this.toolTip.isDrawn)
this.toolTip.draw(); this.state="on"; var button=this; window.setTimeout(function() { button._deactivate(); }, 250); }, deactivate: function() { var margins = this.options.offimgpos.split(' '); this.element.childNodes[0].style.marginLeft = margins[0]; this.element.childNodes[0].style.marginTop = margins[1]; this.state='off'; }
}
}
}); o2.mapy.ToolTip=o2.ClassCreate(o2.mapy.MapStaticLayer, { defaultOptions: { positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(0, 0)), style: { background: "#fff", border: "solid"
}, clickable: true
}, defaultControllers: function() { return new Array( { event: "click", func: o2.FunctionBindAsEventListener(
function(event) { this.clear(); }, this
) }
); }, draw: function($super) { $super(); var toolTip=this; this.timeout=window.setTimeout(function() { if(toolTip.isDrawn)
toolTip.clear(); }, 5000); }, clear: function($super) { $super(); window.clearTimeout(this.timeout); }, toString: function() { return "o2.mapy.ToolTip"; }
}); o2.mapy.ControlButton=o2.ClassCreate(o2.mapy.Button, { group: "ControlButton", defaultOptions: { positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(0, 0)), softactivation: "time", size: new o2.mapy.Size(25, 25), clickable: true, style: { overflow: "hidden"
}, onimgpos: "0px 0px", offimgpos: "0px 0px", drawtest: function() { return false; }, func: function() { throw new Error("Musisz utworzyć realizację tej klasy"); }
}, image: "http://mapapi.o2.pl/api/images/mapcontrol/buttons.png?rev=3571", imageSize: new o2.mapy.Size(163, 50), eventSpace: new o2.EventDispatcher(), initialize: function($super, options) { $super(options, ""); }, on: function() { (this.options.func)(); return true; }, off: function() { return true; }, toString: function() { return "o2.mapy.ControlButton"; }
}); o2.mapy.Slider=o2.ClassCreate(o2.mapy.MapStaticLayer, { group: "ControlButton", zoomArray: new Array(123, 113, 103, 93, 83, 73, 63, 53, 43, 33, 23, 13), defaultOptions: { positioner: new o2.mapy.FixedPositionStrategy(0, 0), clickable: true, size: new o2.mapy.Size(19,135), style: { backgroundImage: "url(http://mapapi.o2.pl/api/images/mapcontrol/slider_scale.png?rev=3571)", backgroundRepeat: "no-repeat", width: "19px", height: "135px"
}
}, initialize: function ($super, position) { var html=document.createElement("div"); this.handleElement=document.createElement("div"); o2.ObjectExtend(
this.handleElement.style, { background: "url(http://mapapi.o2.pl/api/images/mapcontrol/slider_handler_unpressed.gif?rev=3571)", backgroundRepeat: "no-repeat", width: "19px", height: "10px", fontSize: "0px", cursor: "pointer", position: "relative", top: "0px", bottom: "0px", overflow: "hidden"
}
); this.handleElement.position=0; html.appendChild(this.handleElement); $super(html, {positioner: new o2.mapy.FixedPositionStrategy(position)}); this.mouseMove=o2.FunctionBindAsEventListener(this.moveHandle, this); this.mouseUp=o2.FunctionBindAsEventListener(this.dropHandle, this); }, draw: function($super) { this.setLevel({zoom: this.map.getZoom()}); $super(); o2.Event.observe(this.element, "mousedown", o2.FunctionBindAsEventListener(this.mousedown, this)); this.map.bindAsEventListener(this, "centerset", this.setLevel); }, setLevel: function(event) { var pos=123-10*(event.zoom-6); this.handleElement.style.marginTop=pos + "px"; this.handleElement.position=pos; }, getZoomFromPosition: function(position) { var i=0; while(position<this.zoomArray[i])
i++; return i+6; }, mousedown: function(event) { this.handleElement.style.background = 'url(http://mapapi.o2.pl/api/images/mapcontrol/slider_handler_pressed.gif?rev=3571)'
o2.Event.observe(this.element, 'mouseup', this.mouseUp); o2.Event.observe(this.element, 'mouseout', this.mouseUp); this.reference=event.layerY || event.offsetY; if(o2.Event.element(event)==this.handleElement)
this.reference+=parseInt(this.handleElement.style.marginTop); else
this.setLevel({zoom: this.getZoomFromPosition(this.reference)}); o2.Event.observe(this.element, 'mousemove', this.mouseMove); o2.Event.stop(event); }, moveHandle: function(event) { var y=event.layerY || event.offsetY; if(o2.Event.element(event)==this.handleElement)
y+=parseInt(this.handleElement.style.marginTop); this.handleElement.position=this.handleElement.position+y-this.reference; if(this.handleElement.position<3 || 123<this.handleElement.position) { this.dropHandle({type: "scaleout", stopped: true}); return; }
this.handleElement.style.marginTop=this.handleElement.position + "px"; this.reference=y; o2.Event.stop(event); }, dropHandle: function(event) { if(event.type=="mouseout") { var relatedTarget=event.relatedTarget || event.toElement; if(relatedTarget==this.element || relatedTarget==this.handleElement)
return; }
this.handleElement.style.background = 'url(http://mapapi.o2.pl/api/images/mapcontrol/slider_handler_unpressed.gif?rev=3571)'
o2.Event.stopObserving(this.element, "mousemove", this.mouseMove); o2.Event.stopObserving(this.element, "mouseup", this.mouseUp); o2.Event.stopObserving(this.element, "mouseout", this.mouseUp); this.map.setCenter(this.map.getCenter(), this.getZoomFromPosition(parseInt(this.handleElement.style.marginTop))); o2.Event.stop(event); }, toString: function() { return "o2.mapy.Slider"; }
}); o2.ImageCache('http://mapapi.o2.pl/api/images/mapcontrol/slider_handler_pressed.gif?rev=3571'); o2.mapy.SmallMapControl=function(map, position) { var buttons=new Array(
new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x, position.y)), size: new o2.mapy.Size(19, 19), eventword: "zoomin", offimgpos: "-125px 0px", onimgpos: "-125px -19px", func: o2.FunctionBind(map.zoomin, map) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+1, position.y+22)), size: new o2.mapy.Size(19, 19), eventword: "zoomout", offimgpos: "-145px 0px", onimgpos: "-145px -19px", func: o2.FunctionBind(map.zoomout, map) })
); map.addOverlay.apply(map, buttons); }; o2.mapy.BigMapControl=function(map, position) { var buttons=new Array(
new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+28, position.y)), eventword: "panup", offimgpos: "-75px 0px", onimgpos: "-75px -25px", func: o2.FunctionBind(map.pan, map, [0, 1], 200) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x, position.y+28)), eventword: "panleft", offimgpos: "-25px 0px", onimgpos: "-25px -25px", func: o2.FunctionBind(map.pan, map, [1, 0], 200) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+56, position.y+28)), eventword: "panright", offimgpos: "-50px 0px", onimgpos: "-50px -25px", func: o2.FunctionBind(map.pan, map, [-1, 0], 200) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+28, position.y+56)), eventword: "pandown", offimgpos: "0px 0px", onimgpos: "0px -25px", func: o2.FunctionBind(map.pan, map, [0, -1], 200) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+28, position.y+28)), eventword: "fit", offimgpos: "-100px 0px", onimgpos: "-100px -25px", func: o2.FunctionBind(map.centerOrReset, map) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+31, position.y+86)), size: new o2.mapy.Size(19, 19), eventword: "zoomin", offimgpos: "-125px 0px", onimgpos: "-125px -19px", func: o2.FunctionBind(map.zoomin, map) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+32, position.y+109)), size: new o2.mapy.Size(19, 19), eventword: "zoomout", offimgpos: "-145px 0px", onimgpos: "-145px -19px", func: o2.FunctionBind(map.zoomout, map) })
); map.addOverlay.apply(map, buttons); }; o2.mapy.LargeMapControl=function(map, position) { var buttons=new Array(
new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+28, position.y)), eventword: "panup", offimgpos: "-75px 0px", onimgpos: "-75px -25px", func: o2.FunctionBind(map.pan, map, [0, 1], 200) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x, position.y+28)), eventword: "panleft", offimgpos: "-25px 0px", onimgpos: "-25px -25px", func: o2.FunctionBind(map.pan, map, [1, 0], 200) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+56, position.y+28)), eventword: "panright", offimgpos: "-50px 0px", onimgpos: "-50px -25px", func: o2.FunctionBind(map.pan, map, [-1, 0], 200) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+28, position.y+56)), eventword: "pandown", offimgpos: "0px 0px", onimgpos: "0px -25px", func: o2.FunctionBind(map.pan, map, [0, -1], 200) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+28, position.y+28)), eventword: "fit", offimgpos: "-100px 0px", onimgpos: "-100px -25px", func: o2.FunctionBind(map.centerOrReset, map) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+31, position.y+86)), size: new o2.mapy.Size(19, 19), eventword: "zoomin", offimgpos: "-125px 0px", onimgpos: "-125px -19px", func: o2.FunctionBind(map.zoomin, map) }), new o2.mapy.ControlButton({ positioner: new o2.mapy.FixedPositionStrategy(new o2.mapy.ViewPortPoint(position.x+32, position.y+242)), size: new o2.mapy.Size(19, 19), eventword: "zoomout", offimgpos: "-145px 0px", onimgpos: "-145px -19px", func: o2.FunctionBind(map.zoomout, map) }), new o2.mapy.Slider(new o2.mapy.ViewPortPoint(position.x+31, position.y+105))
); map.addOverlay.apply(map, buttons); }; WMessage = o2.ClassCreate(o2.mapy.MapMessage, { defaultOptions: { positioner: new o2.mapy.CenterMiddlePositionStrategy(), style: {}, clickable: true
}, template: new o2.Template(
'       <div style="background: url(http://wmapa.pl/images/roundedwindow/top_left_border.png?rev=3571) no-repeat;" id="wroundedwindow">'+
'           <div style="background: url(http://wmapa.pl/images/roundedwindow/top_right_border.png?rev=3571) no-repeat 100% 0;">'+
'               <div style="background: url(http://wmapa.pl/images/roundedwindow/top_border.png?rev=3571) repeat-x; margin-top: 0; height: 6px; font-size: 0px; margin-left: 5px; margin-right: 6px;"> </div>'+
'               <div style="padding-left: 5px; background: url(http://wmapa.pl/images/roundedwindow/left_border.png?rev=3571) repeat-y 0 100%">'+
'                   <div style="padding-right: 6px; background: #fff url(http://wmapa.pl/images/roundedwindow/right_border.png?rev=3571) repeat-y right top;">'+
'                       <div style="width:16px;height:16px;background:url(http://wmapa.pl/images/wait.gif?rev=3571) no-repeat;margin:0px auto"></div>' +
'                       <div style="padding: 13px;"><span id="wroundedwindowContent">#{msg}</span></div>'+
'                   </div>'+
'               </div>'+
'               <div style="background: url(http://wmapa.pl/images/roundedwindow/bottom_right_border.png?rev=3571) no-repeat 100% 0; height: 6px; font-size: 0px;">'+
'                   <div style="background: url(http://wmapa.pl/images/roundedwindow/bottom_left_border.png?rev=3571) no-repeat 0 0; height: 6px; font-size: 0px;">'+
'                       <div style="background: url(http://wmapa.pl/images/roundedwindow/bottom_border.png?rev=3571) repeat-x; margin-top: 0; height: 6px; font-size: 0px; margin-left: 5px; margin-right: 6px;"> </div>'+
'                   </div>'+
'               </div>'+
'           </div>'+
'       </div>'
) }); o2.ImageCache("http://wmapa.pl/images/wait.gif?rev=3571"); WAlert = o2.ClassCreate(o2.mapy.MapAlert, { defaultOptions:{ positioner: new o2.mapy.CenterMiddlePositionStrategy(), style: { zIndex: "1000"
}, clickable: true
}, template: new o2.Template(
'       <div class="close" style="position:absolute;top:7px;right:7px;width:20px;height:20px;cursor:pointer;background:url(http://wmapa.pl/images/dymek_zamykanie.png?rev=3571) no-repeat"></div>' +
'       <div style="background: url(http://wmapa.pl/images/roundedwindow/top_left_border.png?rev=3571) no-repeat;" id="wroundedwindow">'+
'           <div style="background: url(http://wmapa.pl/images/roundedwindow/top_right_border.png?rev=3571) no-repeat 100% 0;">'+
'               <div style="background: url(http://wmapa.pl/images/roundedwindow/top_border.png?rev=3571) repeat-x; margin-top: 0; height: 6px; font-size: 0px; margin-left: 5px; margin-right: 6px;"> </div>'+
'               <div style="padding-left: 5px; background: url(http://wmapa.pl/images/roundedwindow/left_border.png?rev=3571) repeat-y 0 100%">'+
'                   <div style="padding-right: 6px; background: #fff url(http://wmapa.pl/images/roundedwindow/right_border.png?rev=3571) repeat-y right top;">'+
'                       <div style="padding: 13px;"><span id="wroundedwindowContent" style="color: #f00;">#{msg}</span></div>'+
'                       <div style="text-align: center;"><a href="javascript: void(0)" class="close_alert" id="close_alert" style="outline: none;"><img src="http://wmapa.pl/images/ok.png?rev=3571" style="width:55px;height:33px" /></a></div>' +
'                   </div>'+
'               </div>'+
'               <div style="background: url(http://wmapa.pl/images/roundedwindow/bottom_right_border.png?rev=3571) no-repeat 100% 0; height: 6px; font-size: 0px;">'+
'                   <div style="background: url(http://wmapa.pl/images/roundedwindow/bottom_left_border.png?rev=3571) no-repeat 0 0; height: 6px; font-size: 0px;">'+
'                       <div style="background: url(http://wmapa.pl/images/roundedwindow/bottom_border.png?rev=3571) repeat-x; margin-top: 0; height: 6px; font-size: 0px; margin-left: 5px; margin-right: 6px;"> </div>'+
'                   </div>'+
'               </div>'+
'           </div>'+
'       </div>'
), defaultControllers: function() { return new Array( { path: "a.close_alert", event: "click", func: o2.FunctionBindAsEventListener(
function() { this.clear(); }, this
) }, { path: "div.close", event: "click", func: o2.FunctionBindAsEventListener(this.clear, this) }
); }, draw: function($super) { $super(); document.getElementById('close_alert').focus(); }
}); o2.ImageCache("http://wmapa.pl/images/roundedwindow/top_left_border.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/roundedwindow/top_right_border.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/roundedwindow/top_border.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/roundedwindow/left_border.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/roundedwindow/right_border.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/roundedwindow/bottom_right_border.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/roundedwindow/bottom_left_border.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/roundedwindow/bottom_border.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/dymek_zamykanie.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/ok.png?rev=3571"); SmallPoiWindow=o2.ClassCreate(o2.mapy.Window,{ group: "SmallPoiWindow", defaultOptions: { clickable: true, draggable: false, displacement: "203, 69s", style: { zIndex: "998"
}, panmapstrategy: { type: "toviewport", top: 60, left: 60, bottom: 40
}, shadow: { displacement: "203, 38s", size: new o2.mapy.Size(284, 31), clickable: false, style: { backgroundImage: "url(http://wmapa.pl/images/poiwindow/small/dymek.png?rev=3571)", zIndex: "998"
}
}
}, defaultControllers: function() { return new Array( { path: "div.t_smallpoi_closer", event: "click", func: o2.FunctionBindAsEventListener(this.clear, this) }
); }, template: new o2.Template(
'<div style="width: 284px; height: 4px; font-size: 0px; '+o2.AlphaImage('http://wmapa.pl/images/poiwindow/small/allimages.png?rev=3571')+'; background-position: 0px 0px; background-repeat: no-repeat;"> </div>'+
'<div style="background: url(http://wmapa.pl/images/borders.png?rev=3571) repeat-y left;">' +
'   <div style="background: url(http://wmapa.pl/images/borders.png?rev=3571) repeat-y right;">' +
'       <div style="background-color: #fff; margin: 0 2px;">'+
'	        <div class="t_smallpoi_closer" style="font-size: 0px; width: 12px; height: 12px; background-image: url(http://wmapa.pl/images/poiwindow/small/allimages.png?rev=3571); background-position: 0px -37px; background-repeat: no-repeat; position: absolute; top: 12px; right: 12px; cursor: pointer"></div>' +
'           <div style="overflow: hidden; width: 280px;">'+
'               <div style="margin: 11px 10px 0 10px;">'+
'                   <div style="width: 225px; font-size: 17px">'+
'                       #{name}' +
'                   </div>'+
'               </div>'+
'               <div style="margin: 10px; font-size: 13px;">'+
'					<p style="margin: 0px; padding:0px">#{generatedAddress}</p>'+
'					<p style="margin: 0px; padding:0px">#{phone}</p>' +
'					<p style="margin: 0px; padding:0px">' +
'						<a target="_blank" href="#{www}">#{www}</a>' +
'					</p>' +
'               </div>'+
'           </div>'+
'       </div>'+
'   </div>' +
'</div>'
), initialize:function($super, point, options) { options.substitute.generatedAddress = this.generateAddress(options.substitute); $super(point, "", options); var substitute=o2.ObjectExtend({}, this.options.substitute); if(substitute.description=="")
substitute.description=" "; else
substitute.description='<div style="width:630px;height:170px;overflow:auto">' +
'<p style="clear: both; padding: 0px 8px;">' +
'<strong>Opis:</strong> ' + substitute.description +
'</p>' +
'</div>'; }, generateAddress: function(data) { var address = data.city; if(data.street.length > 0)
address += ', '+data.street; if(data.number.length > 0)
address += ' '+data.number; if(data.local.length > 0)
address += '/'+data.local; return address; }
}); o2.ImageCache("http://wmapa.pl/images/borders.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/poiwindow/small/allimages.png?rev=3571"); PoiMarker = new o2.ClassCreate(o2.mapy.Marker, { group: "PoiMarker", defaultOptions: { clickable: true, draggable: false, size: new o2.mapy.Size(29, 40), displacement: "14, 0s", style: { textAlign: "center", backgroundImage: "url(http://wmapa.pl/images/bluegradientmarker.png?rev=3571)", color: "#f56e00", fontWeight: "bold", fontSize: "11px", cursor: "pointer"
}, panmapstrategy: { type: "none"
}
}, initialize: function($super, point, options, id) { this.id = id; $super(point, options); }
}); getPoi={ waiter: new WMessage('Ładowanie&nbsp;punktu...'), errorAlert: new WAlert('Na&nbsp;mapie&nbsp;powinien&nbsp;pojawić&nbsp;się&nbsp;punkt, ale&nbsp;nie&nbsp;można&nbsp;go&nbsp;wyświetlić.'), setMap: function(map) { this.map=map; this.waiter.setMap(map); this.errorAlert.setMap(map); }, getPoiXHR: function(poiId) { var req = new o2.AjaxRequester(
"/s_poi/getdescription", { params: {id: poiId}, asynchronous: false, onSuccess: o2.FunctionBindAsEventListener(this.onSuccess, this.map), onFailure: o2.FunctionBindAsEventListener(this.onFailure, this.map), onException: o2.FunctionBindAsEventListener(this.onException, this.map) }
); map.addOverlay(this.waiter); req.doRequest(); }, onSuccess: function(response) { if(response.responseJSON.length==0) { getPoi.onFailure(); return ; }
getPoi.waiter.clear(); var json=response.responseJSON[0]; var lnglat=new o2.mapy.LngLat(json.lng, json.lat); poiMarker=new PoiMarker(
lnglat, { content: { draw: true, layer: new SmallPoiWindow(lnglat, {substitute: json}) }
}, json.id
); poiMarker.group="poiMarker"; this.setCenter(lnglat, 15); this.addOverlay(poiMarker); }, onFailure: function(response) { getPoi.waiter.clear(); getPoi.errorAlert.draw(); }, onException: function(response) { getPoi.waiter.clear(); getPoi.errorAlert.draw(); }, getPoiInj: function(poiId) { var req=new o2.HamletRequester(
"http://wmapa.pl/s_poi/getdescription", { parameters: { id: poiId, referer: "embed"
}
}
); this.waiter.draw(); req.doRequest(); }
}; NoteWindow=o2.ClassCreate(o2.mapy.Window, { group: "NoteWindow", defaultOptions: { clickable: true, draggable: false, displacement: "61, 94s", style: { fontSize: "13px", zIndex: "999"
}, panmapstrategy: { type: "toviewport", top: 60, left: 60, bottom: 40
}, shadow: { displacement: "61, 35s", size: new o2.mapy.Size("auto", 59), clickable: false, style: { backgroundImage: "url(http://wmapa.pl/images/notewindow/dymek.png?rev=3571)", zIndex: "999"
}
}
}, defaultControllers: function() { return new Array( { path: "div.t_note_closer", event: "click", func: o2.FunctionBindAsEventListener(this.clear, this) }
); }, template: new o2.Template(
'<div style="width:404px;height:4px;font-size:0px;'+o2.AlphaImage('http://wmapa.pl/images/notewindow/allimages.png?rev=3571')+'; background-position: 0px 0px; background-repeat: no-repeat;"> </div>'+
'<div style="background: url(http://wmapa.pl/images/borders.png?rev=3571) repeat-y left;">' +
'   <div style="background: url(http://wmapa.pl/images/borders.png?rev=3571) repeat-y right;">' +
'       <div style="background-color: #fff; margin: 0 2px;">'+
'	        <div class="t_note_closer" style="font-size: 0px; width: 12px; height: 12px; background-image: url(http://wmapa.pl/images/notewindow/allimages.png?rev=3571); background-position: 0px -65px; background-repeat: no-repeat; position: absolute; top: 12px; right: 12px; cursor: pointer"></div>' +
'           <div style="overflow: hidden; width: 400px;">'+
'               <div style="margin: 10px 10px 0 10px;">'+
'                   <div style="float: left; background-image: url(http://wmapa.pl/images/notewindow/allimages.png?rev=3571); background-position: -13px -65px; background-repeat: no-repeat; width: 17px; height: 20px;"></div>'+
'                   <div style="float: left; width: 150px; font-size: 19px; line-height: 18px; margin-left: 5px;">Notka</div>'+
'               </div>'+
'               <div style="clear: both; margin: 0px 8px;">'+
'                   <label for="addnote_content" style="display: block; padding-top: 5px; font-size: 13px;">Treść:</label>'+
'                   <textarea id="addnote_content" tabindex="600" cols="30" rows="9" readonly="readonly" style="border: solid 1px #c6c5c3; width: 99%; font-size: 11px; margin: 0px 0px 10px 2px">#{content}</textarea>' +
'                   <input class="noteurl" value="" id="TAddedPointSummary_focusElement" type="text" style="width: 96.5%; margin-top: 7px; border: solid 1px gray; -moz-border-radius: 3px; border-radius: 3px; -webkit-border-radius: 3px; padding: 4px; height: 18px;" onfocus="this.select()" onclick="this.select()" tabindex="11"  readonly="readonly" /><br />' +
'               </div>'+
'               <div style="font-size:0px;margin-top:10px"></div>' +
'           </div>'+
'       </div>'+
'   </div>' +
'</div>'
), updateHash: function(hash) { o2.ElementSelect(this.element, "input", "noteurl")[0].value="http://wmapa.pl/#ni=" + hash; }
}); o2.ImageCache("http://wmapa.pl/images/borders.png?rev=3571"); o2.ImageCache("http://wmapa.pl/images/notewindow/allimages.png?rev=3571"); NoteMarker=o2.ClassCreate(o2.mapy.Marker, { group: "NoteMarker", defaultOptions: { clickable: true, draggable: false, size: new o2.mapy.Size(27,39), displacement: "13, 0s", style: { backgroundImage: "url(http://wmapa.pl/images/notemarker.png?rev=3571)"
}, panmapstrategy: { type: "none"
}
}
}); getNote={ waiter: new WMessage('Ładowanie&nbsp;notki...'), errorAlert: new WAlert('Na&nbsp;mapie&nbsp;powinna&nbsp;pojawić&nbsp;się&nbsp;notka, ale&nbsp;nie&nbsp;można&nbsp;jej&nbsp;wyświetlić.'), setMap: function(map) { this.map=map; this.waiter.setMap(map); this.errorAlert.setMap(map); }, getNoteXHR: function(hash) { var req = new o2.AjaxRequester(
"/s_note/getnote", { params: {id: hash}, asynchronous: false, onSuccess: o2.FunctionBindAsEventListener(this.onSuccess, this.map), onFailure: o2.FunctionBindAsEventListener(this.onFailure, this.map), onException: o2.FunctionBindAsEventListener(this.onException, this.map) }
); this.waiter.draw(); req.doRequest(); }, onSuccess: function(response) { getNote.waiter.clear(); var lnglat=new o2.mapy.LngLat(response.responseJSON.lng, response.responseJSON.lat); this.setCenter(lnglat, parseInt(response.responseJSON.zoom)); var noteWindow=new NoteWindow(lnglat, response.responseJSON.note); var noteMarker = new NoteMarker(
lnglat, { content: { draw: true, layer: noteWindow
}
}
); this.setCenter(lnglat, 15); this.addOverlay(noteMarker); noteMarker.hash=response.responseJSON.id; noteWindow.updateHash(response.responseJSON.id); }, onFailure: function(response) { getNote.waiter.clear(); getNote.errorAlert.draw(); }, onException: function(response) { getNote.waiter.clear(); getNote.errorAlert.draw(); }, getNoteInj: function(hash) { var req=new o2.HamletRequester(
"http://wmapa.pl/s_note/getnote", { parameters: { id: hash, referer: "embed"
}
}
); this.waiter.draw(); req.doRequest(); }
}; WMapaLink=o2.ClassCreate(o2.mapy.MapStaticLayer, { defaultOptions: { clickable: true, positioner: new o2.mapy.RightBottomPositionStrategy(new o2.mapy.ViewPortPoint(-5, -5)), style: { border: "1px solid #ddd", background: "#fff"
}
}, initialize: function($super, options) { $super('&nbsp;<a href="http://wmapa.pl/" style="color:blue;font-family:Verdana;font-size:12px;text-decoration:underline">www.wmapa.pl</a>&nbsp;', options); }
}); var divId="o2_map_div"; while(document.getElementById(divId)!=null)
divId=divId + "I"; document.write('<div style="width:' + o2_map.width + 'px; height:' + o2_map.height + 'px" id="o2_map_div"></div>'); o2_map=o2.ObjectExtend( { draggable: true, width: 400, height: 300, zoom: 7, center: [19.50625,52.02510758314961], spider: "none"
}, o2_map
); o2_map.map = new o2.mapy.Map(divId); o2_map.map.setCenter(new o2.mapy.LngLat(o2_map.center[0], o2_map.center[1]), o2_map.zoom); if (o2_map.draggable)
o2_map.map.enableDragging(); else
o2_map.map.disableDragging(); var position=new o2.mapy.ViewPortPoint(5, 5); switch (o2_map.spider) { case "none": break; case "small": o2.mapy.SmallMapControl(o2_map.map, position); break; case "big": o2.mapy.BigMapControl(o2_map.map, position); break; default: o2.mapy.LargeMapControl(o2_map.map, position); }
if(o2_map.note) { getNote.setMap(o2_map.map); getNote.getNoteInj(o2_map.note); }
if(o2_map.poi) { getPoi.setMap(o2_map.map); getPoi.getPoiInj(o2_map.poi); }
o2_map.map.addOverlay(new WMapaLink());