var _maplib_icons=[]; var _maplib_maps=[]; var _marker_id=0; var _markers_info=[]; var _markers_list=[]; var _markers=[]; var _stype=0; createBasicIcon(); function Mmap(mid,container,lat,lng,level,records,orderby) { if (container!=null) { this.lat=-53.71621563247202; this.lng=35.2880859375; this.level=7; this.records=30; this.orderby=0; if (lat!=null) { this.lat=lat; } if (lng!=null) { this.lng=lng; } if (level!=null) { this.level=level; } if (records!=null) { this.records=records; } if (orderby!=null) { this.orderby=orderby; } this.container=container; this.mid=mid; this.hash="07cc694b9b3fc636710fa08b6922c42b"; this.overlays = []; this.loaded=0; _maplib_maps.push(this); this.index=_maplib_maps.length; var _url=window.location+""; var _results=_url.match(/#maplib([0-9]+)/); if (_results!=null) { _marker_id=_results[1]; } else { _marker_id=0; } } } function _map_init(index,i,a,p,d) { if (index>0) { var m= _maplib_maps[index-1]; m.iz=i; m.az=a; m.path=p; m.dir=d; m.drawMap(); } } Mmap.prototype.initMap = function() { if (this.loaded<1) { var url="http://www.maplib.net/api/api.php?a=mapInfo&mapid="+this.mid+"&n="+this.index+"&hash="+this.hash; GScript(url); } } Mmap.prototype.drawMap = function() { var _this=this; if (this.loaded<1) { this.map = new GMap2(this.container,{mapTypes:[]}); GEvent.addListener(this.map,'addoverlay',function(o){ _this.overlays.push(o); }); GEvent.addListener(this.map,'removeoverlay',function(o){ for(var i = 0; i < this.overlays.length; i++) if(_this.overlays[i] === o) return _this.overlays.splice(i,1); }); GEvent.addListener(this.map,'clearoverlays',function(){ _this.overlays = []; }); var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, "©2008 MapLib.net"); var copyrightCollection = new GCopyrightCollection('Map Data:'); copyrightCollection.addCopyright(copyright); var p=this.path; var d=this.dir; var iz=this.iz; var az=this.az; var tilelayers = [new GTileLayer(copyrightCollection,7,17-iz)]; tilelayers[0].getTileUrl = function(a,b){ return "http://www.maplib.net/mapdata/"+d+p+"/"+a.x+"_"+a.y+"_"+(17-b)+".gif"; } var custommap = new GMapType(tilelayers, G_NORMAL_MAP.getProjection(), "MapLib"); this.map.addMapType(custommap); this.map.setCenter(new GLatLng(this.lat,this.lng),this.level,custommap); //this.omap=new GOverviewMapControl(new GSize(200,200)); //this.map.addControl(this.omap); //this.omap.hide(true); this.loaded=1; var m_doc=document.getElementsByTagName('body').item(0); var js = document.createElement('div'); js.setAttribute('id', 'powered_by_maplib'); js.innerHTML=""; m_doc.appendChild(js); var pos2= new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(64,0)); pos2.apply(document.getElementById("powered_by_maplib")); this.map.getContainer().appendChild(document.getElementById("powered_by_maplib")); this.map.addControl(new GLargeMapControl()); this.map.enableScrollWheelZoom(); } } Mmap.prototype.getMap = function() { return this.map; } Mmap.prototype.showMarkers = function(aid) { _markers_list=[]; _markers_info=[]; var amount=getQueryString("page"); var url="http://www.maplib.net/api/api.php?a=show_markers&mapid="+this.mid+"&n="+this.index+"&hash="+this.hash+"&markerid="+_marker_id+"&amount="+amount+"&records="+this.records+"&orderby="+this.orderby; GScript(url); } function _map_clearOverlays(index) { if (index>0) { var m= _maplib_maps[index-1]; m.map.clearOverlays(); _markers=[]; } } function _map_createMarker(index,lng,lat,tooltip,introduction,iconid,icon,iwidth,iheight,id,zoom,markerid,lc,lw,lo,fc,fo,data,stype) { if (index>0) { var m= _maplib_maps[index-1]; if (!_maplib_icons[iconid]) { createIcon(iconid,icon,iwidth,iheight); } var pos=new GLatLng(lat,lng); if (stype==0) { var marker = new GMarker(pos,{icon:_maplib_icons[iconid],title:tooltip}); } else if (stype==1) { var marker=new GPolyline(data.parseJSON(),lc,lw); } else if (stype==2) { var marker=new GPolygon(data.parseJSON(),lc,lw,lo/100,fc,fo/100); } if ((stype<3)&&(stype>=0)) { marker.id=id; marker.group=iconid; //m.map.addOverlay(marker); _markers.push(marker); var _html=generateInfo(tooltip,introduction,id); _markers_info.push(_html); _markers_list.push(id); GEvent.addListener(marker, "click", function() { _map_recenter(index,lat,lng,zoom,stype,id); }); if (_marker_id==id) { _stype=stype; m.map.panTo(new GLatLng(lat, lng)); m.map.setZoom(zoom); } /* if (markerid==id) { m.map.closeInfoWindow(); m.map.panTo(new GLatLng(lat, lng)); m.map.setZoom(zoom); //if (stype==0) //marker.openInfoWindowHtml(_html); //else //{ // m.map.openInfoWindowHtml(marker.getVertex(0),_html); //} }*/ } } } Mmap.prototype.addLegendControl = function (elem) { if (elem!=null) { var url="http://www.maplib.net/api/api.php?a=listLegend&mid="+this.mid+"&n="+elem.id+"&index="+this.index+"&hash="+this.hash; GScript(url); } } function displayMarkers2() { if (_Browser.Version()==8) { setTimeout(displayMarkers,5000); } else { displayMarkers(); } } function displayMarkers() { for (var j=0;j<_markers.length;j++) { mm.map.addOverlay(_markers[j]); if (_marker_id==_markers_list[j]) { _html=_markers_info[j]; if (_stype==0) _markers[j].openInfoWindowHtml(_html); else { mm.map.openInfoWindowHtml(_markers[j].getVertex(0),_html); } } } } Mmap.prototype.listMarkers = function (elem) { if (elem!=null) { var amount=getQueryString("page"); var url="http://www.maplib.net/api/api.php?a=listMarkers&mid="+this.mid+"&n="+elem.id+"&index="+this.index+"&hash="+this.hash+"&amount="+amount+"&records="+this.records+"&orderby="+this.orderby+"&markerid="+_marker_id; GScript(url); } } Mmap.prototype.addListener =function (event,handler) { GEvent.addListener(this.map,event,handler); } Mmap.prototype.clearListeners =function (event) { GEvent.addListener(this.map,event); } function include_dom(script_filename) { var html_doc = document.getElementsByTagName('head').item(0); var js = document.createElement('script'); js.setAttribute('language', 'javascript'); js.setAttribute('type', 'text/javascript'); js.setAttribute('src', script_filename); html_doc.appendChild(js); return false; } function _map_html(elemid,html) { document.getElementById(elemid).innerHTML=html; } function centerPoint(p1,p2) { return new GLatLng((p1.lat()+p2.lat())/2,(p1.lng()+p2.lng())/2); } function _map_recenter(index,latitude,longitude,zoom,stype,mid) { if (index>0) { var m = _maplib_maps[index-1]; m.map.closeInfoWindow(); m.map.panTo(new GLatLng(latitude, longitude)); m.map.setZoom(zoom); for (var j=0;j0) { var m = _maplib_maps[index-1]; for (var x=0;x0) { m.overlays[x].show(); } else { m.overlays[x].hide(); } } } var tbl="maplib_markers_"+index; if (document.getElementById(tbl).rows.length>0) { var tdlist=document.getElementById(tbl).getElementsByTagName('tr'); for (var j=0; j0) { if (flag>0) { tdlist[j].style.display="block"; } else { tdlist[j].style.display="none"; } } } } } } function rand() { return "&rand="+(Math.random()*Math.random()); } function loading() { } function done() { } function failure() { alert('oops...errors occurred'); } function generateInfo(tooltip,html,markerid) { html=html.replace(/\[b\](.*?)\[\/b\]/i,"$1"); html=html.replace(/\[i\](.*?)\[\/i\]/i,"$1"); html=html.replace(/\[u\](.*?)\[\/u\]/i,"$1"); html=html.replace(/\[img\](.*?)\[\/img\]/i,""); html=html.replace(/\[url\](.*?)\[\/url\]/i,"$1"); html=html.replace(/\[url\=(.*?)\](.*?)\[\/url\]/i,"$2"); html2="
"+tooltip+"  

"+html; html2=html2+"
more...
"; return html2; } function createBasicIcon(){ _maplib_icons.basic = new GIcon(); _maplib_icons.basic.image = "http://www.maplib.net/markers/basic.png"; _maplib_icons.basic.iconSize = new GSize(20,34); _maplib_icons.basic.iconAnchor = new GPoint(6,20); _maplib_icons.basic.infoWindowAnchor = new GPoint(5,1); _maplib_icons.basic.imageMap = [5,0, 1,4, 1,8, 3,12, 5,20, 7,20, 8,12, 11,8, 11,4, 7,0]; } function createIcon(iconid,imgfile,iw,ih) { imgfile=imgfile.replace(/\.\//i,"http://www.maplib.net/"); _maplib_icons[iconid]=new GIcon(_maplib_icons.basic,imgfile); if (iw>0) { _maplib_icons[iconid].iconSize=new GSize(iw,ih); } } function getQueryString(sProp) { var re=new RegExp(sProp+"=([^\\&]*)","i"); var a=re.exec(document.location.search); if (a==null) return ""; return a[1]; }; var _Browser = { Version: function() { var version = 999; if (navigator.appVersion.indexOf("MSIE") != -1) version = parseFloat(navigator.appVersion.split("MSIE")[1]); return version; } } function GScript(src) {document.write('<' + 'script src="' + src + '"' +' type="text/javascript"><' + '/script>');} if(!Object.prototype.toJSONString){Array.prototype.toJSONString=function(_){var A=[],$,B=this.length,C;for($=0;$