var scripts=document.getElementsByTagName("script"); var CurrentScript=scripts[scripts.length-1]; addEvent(window, "load", function(){ GMW.create(); GMW_MAP.init(GMW.EXT_PARAMS.map_holder); }); var GMW_MAP={ init:function(id){ if (!GBrowserIsCompatible()) return; addEvent(window, "unload", GUnload); this.block=document.getElementById(id); map = new GMap2(this.block); geocoder = new GClientGeocoder(); //map.setUIToDefault(); map.enableScrollWheelZoom(); map.enableContinuousZoom(); map.disableInfoWindow(); var latlng=GMW.EXT_PARAMS.latlng; map.setCenter(new GLatLng(GMW.EXT_PARAMS.latlng&&GMW.EXT_PARAMS.latlng[0]?GMW.EXT_PARAMS.latlng[0]:52.527000, GMW.EXT_PARAMS.latlng&&GMW.EXT_PARAMS.latlng[1]?GMW.EXT_PARAMS.latlng[1]:13.408000), GMW.EXT_PARAMS.zoom || 11); }, //create single marker and attach event on it createMarker:function(point){ var cIcon=this.marker("gmw_m"+GMW.res.categories[point.cId].icon+".png"); var opts = { "icon": cIcon, "clickable": true, "draggable": false }; var marker = new GMarker(new GLatLng(point.lat, point.lon), opts); marker.href=point.href; marker.tooltip=point.tooltip; if(point.url || point.link) GEvent.addListener(marker, "click", function() { location.href=point.url || point.link; }); GEvent.addListener(marker, "mouseover", function() { GMW_Tooltip.show(marker, point); }); GEvent.addListener(marker, "mouseout", function() { GMW_Tooltip.hide(); }); return marker; }, // draw/redraw markers on the map drawMarkers:function(points){ this.clear(); var markers=[]; for(var i in points){ var marker=this.createMarker(points[i]); markers.push(marker); map.addOverlay(marker); } this.setViewPort(points); }, clear:function clearMarkers(){ if(map) map.clearOverlays(); }, getViewPort:function(){ var bounds = Map.boundsNormalize(map.getBounds()); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); return {n:{lng:northEast.lng(),lat:northEast.lat()},s:{lng:southWest.lng(),lat:southWest.lat()}}; }, setViewPort:function(points){ if(!points || !points[0]) return false; //get markers view zone on map, return rectangle bounds var exists, n_lng, n_lat, s_lng, s_lat; for(var i in points){ n_lng=!exists || (exists && Number(points[i]["lon"])>n_lng)?Number(points[i]["lon"]):n_lng; n_lat=!exists || (exists && Number(points[i]["lat"])>n_lat)?Number(points[i]["lat"]):n_lat; s_lng=!exists || (exists && Number(points[i]["lon"]) call data from cache & return try{if(this.caching && this.CACHE[this.query]) return this.ondata(this.CACHE[this.query]);}catch(e){}; var _this=this; var request, response; var SID=(new Date()).getTime()+Math.round(Math.random()*1000); switch(this.method){ case "http": request=window.XMLHttpRequest?new XMLHttpRequest():(new ActiveXObject("Msxml2.XMLHTTP") || null); // ||"Microsoft.XMLHTTP" - ie5x if(request){ request.open('POST', this.file, true); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // $_POST[] || $_REQUEST[] request.onreadystatechange=function(){ if(request.readyState==4){ try{ if(request.getResponseHeader('Content-Type') && request.getResponseHeader('Content-Type').indexOf("/xml")!=-1) response=_this.xml2json(request); //xml else response=(new Function('return '+request.responseText))(); //json } catch(e){_this.onerror(request.responseText)} _this.ondata(response); } }; request.send(this.query); //request send break; } case "script": request=document.createElement("script"); if(request){ request.id=SID; var src=this.file+"?"+"_scriptID_="+request.id+"&"+this.query; if(BROWSER.ie) request.src=src.substr(0,2048); //MAX msie:2kb else{request.src=src; request.src=request.src.substr(0,4096)}; //MAX gesko:4Kb request.onreadystatechange=function(response){ if(response && !response.initEvent){ _this.ondata(response); setTimeout(function(){request.parentNode.removeChild(request)},13); } }; document.body.appendChild(request); //request send break; } default: return request; } }, ondata:function(response){ if(this.caching || this.CACHE[this.query]) this.CACHE[this.query]=response; //cache response data this.response=response; this.onready(response); }, json2query:function(hash, pref){ var query=""; for(var i in hash){ if(!i) continue; var key=(pref?pref+"["+i+"]":i); query+=(typeof hash[i]=="object" ? this.json2query(hash[i],key) : "&"+key+"="+hash[i].toString().replace(/&/g, "%26")); } return query; }, xml2json:function(request){ var parseXML=function(node){ if(node.childNodes.length==1 && (node.firstChild.nodeType==3 || node.firstChild.nodeType==4)) return node.firstChild.data; //if text node var hash={}; for(var i=0, childs=node.childNodes, l=childs.length; i