О немО себе[code]/maps/Мои СоседиМой ЗимаШопМоя СтройкаЗверь Дверь
[code] | kMaps | ZTile.js
kMaps
    ZTile.js
4D
  auto_registrator_cc.c
  array-speed.php
  time.php
  auto_registrator.c
  ed_line.c
  SparseTileLayer.js
  codeZ.php
  ed_line.cc.c
 
/* Kashey`s utimate solution for tiled loading of map data */


window.tile_isset = function (a){ return && typeof(a)!='undefined';}


function 
TileTale(map)
{

}

var 
ZM_FACTOR=1000000;

TileTale.prototype.init = function ( map )
{
this.map map;
    
this.nav_objects          =[];
    
this.nav_block_index      =[];
    
this.nav_layers           =[];
    
this.objects_to_hide      =[];
    
this.objects_to_show      =[];
    
    
this.NavRequestsAjaxian   =[];
    
this.NavRequestImage      =[];
    
this.NavRequestsTimes     =[];
    
    
this.new_objects          =[];
    
this.render_objects       =[];
    
this.active_render        =[];
    
this.thisBounds           ={};
    
    
this.layerEvents          =[];
    
    
this.NowRequestingCnt     =0;
    
    
this.realrender           =[];
    
    
this.LIMIT_OBJECTS        =150;
    
this.ZTILE_RENDER_LIMIT   =35;
    
this.RENDER_TIME_STEP     =0;
    
    
this.layerSet             =[];
    
    
this.layerEvents          =new Array();
    
    
this.widthDivCounter      =11;
    
    
this.objectUsageCounter   1;
        
    
this.ts_queryRender        =0;
    
this.ts_queryRender2       =0;
    
    
this.requestTimeShift     300;
    
    
this.allowBlockRequests   1;
    
this.allowSortRender      1;
    
this._collapceCounter     0;
    
    
this.ZoomOffset           0;
    
    
this._tiledebug           0;
    
this.zBurstLimit          4;
    
    
this.renderHide_tm        =0;
    
this.hideAll_Tm           =0;
    
this.inqueryRenderCnt     =0;
    
    
this.generationCounter    0;
    
    
this.renderPipeline       = [];
    
this.visiblePipeline      = [];
    
    
this.objectHashCounter    0;
     
    
this.y_consar=new Array(-85051128,-83979259,-82676284,-81093213,-79171334,-76840816,-74019543,-70612614,-66513260,-61606396,-55776579,-48922499,-40979898,-31952162,-21943045,-11178401,0,11178401,21943045,31952162,40979898,48922499,55776579,61606396,66513260,70612614,74019543,76840816,79171334,81093213,82676284,83979259,85051128);
    
    
this.absoluteObjectCounter=0;
    
    
this.config_TimeredLoad 1;
    
this.injectDirectObject 1;
    
this.dirrectObjects     = [];
    
    
this.cluster = new zClusterIndex();
}

TileTale.prototype.microtime = function() {   
    var 
now = new Date().getTime() / 1000;

    return 
now ;
}

TileTale.prototype.newGeneration = function(){
    
this.generationCounter++;
}

TileTale.prototype.currentGeneration = function(){
    return 
this.generationCounter;
}


TileTale.prototype.clearLayersSet=function()
{
    
this.layerSet=[];
    
this.checkObjects();
    
this.queryRender();
}

TileTale.prototype.enableLayer=function(layer,ison)
{
    
ison=typeof(ison)=='undefined'?1:ison;;
    
this.layerSet[layer]=ison?layer:0;
    var 
outset=[];
    for(
i in this.layerSet)
     if(
this.layerSet[i]==i)
      
outset[i]=i;
    
this.layerSet=outset;
    
this.newGeneration();
    
this.checkObjects();
    
this.queryRender();
}

TileTale.prototype.disableLayer=function(layer,ison)
{
    
this.enableLayer(layer,0);
}

TileTale.prototype.checkObjects = function (){
    for(
i in this.nav_objects)
        if(
this.nav_objects[i] && this.nav_objects[i].LATITUDE)
         
this.checkObject(this.nav_objects[i]);
}

TileTale.prototype.injectObject = function (object,layer_id,weight){
    
    var 
idkey=(object['ID_MAP_OBJECT']);
    
object.layers={};
    
object.stacked=[];
    
object.stackedBefore=0;
    
object.stackCNT=0;
    
object.reStack=0;
    
object.generation=this.currentGeneration();
    
    if(!
object.dim)object.dim={w:16,h:16};
    if(!
object.relativeCounter)object.relativeCounter=0;
    if(!
object.storedCapacity)
      
object.storedCapacity=parseFloat(object.CNT);
    
    
object.LATITUDE parseFloat(object.LATITUDE);
    
object.LONGITUDEparseFloat(object.LONGITUDE);
    
    if(!
object.LATITUDE && !object.LONGITUDE){
     return 
false;
    }
    
   
/* var lng=getRandomArbitary(layer.area.x1,layer.area.x2);
    var lat=getRandomArbitary(layer.area.y1,layer.area.y2);
   */
    
    
object.maxLayer=layer_id;
    
object.layers[layer_id]=(layer_id);
    
object.shown=0;
    
object.map_object=0;
    
object.randWeight=this.absoluteObjectCounter++;//weight;
    //Math.ceil(1000000*Math.random()+1000*Math.random()+x);
    
object.stackgroup=0;
    
this.layerCall(object.layers,object,'preprocess');
    
    
this.nav_objects[idkey]=object;                
    
this.new_objects[idkey]=(idkey);
    
    
this.checkObject(this.nav_objects[idkey]);
    
    if(
this.injectDirectObject)
     
this.dirrectObjects[idkey]=idkey;
    
    
this.queryRender();
    return 
object;
}

TileTale.prototype.checkObject = function (obj){
    var 
ison=0;
    for(
j in this.layerSet){
        if(
obj.layers[j]){ ison=1;break;}
    }
    
    var 
newstateison || obj.forceShow;
    if(
obj.layerEnabled != newstate)
     
obj.generation=this.currentGeneration();
    
obj.layerEnabled newstate;
    
    
}

TileTale.prototype.getObjects=function()
{
    return 
this.nav_objects.split(0);
}

TileTale.prototype.getObject=function(id)
{
    return 
this.nav_objects[id];
}

TileTale.prototype.dirrectAccess=function()
{
    return 
this.nav_objects;
}







TileTale.prototype.assignDataCenter = function ()
{
    return 
"/maptiles/";
}


TileTale.prototype.zoomTile=function(code)
{
    var 
x1=-180000000;
    var 
x2180000000;
    var 
y1=-90000000;//85051128;
    
var y290000000;//85051128;
    
var l=code.length;
    for(
i=0;i<l;i++)
    {
      
xdel=Math.round((x1+x2)/2);
      
ydel=Math.round((y1+y2)/2);
      if(
code[i]=='0') {p1=0;p2=0;}
      if(
code[i]=='1') {p1=0;p2=1;}
      if(
code[i]=='2') {p1=1;p2=1;}
      if(
code[i]=='3') {p1=1;p2=0;}
      if(
p1==0){x1=xdel+1}
      else     {
x2=xdel  }
      if(
p2==0){y1=ydel+1;}
      else     {
y2=ydel  ;}  
    }
    var 
points=new Array();
    
points[0]=this.map.getPositionInstance(y1/ZM_FACTOR,x1/ZM_FACTOR);
    
points[1]=this.map.getPositionInstance(y2/ZM_FACTOR,x2/ZM_FACTOR);
    
this.map.zoomToPointSet(points);
}

//ZTile.zoomTile('031023131210');


TileTale.prototype.checkPoint=function (x,y,xline,yline,curzoomkv)
{
    var 
xdel=0;
    var 
ydel=0;
    var 
x1=-180000000;
    var 
x2180000000;
    var 
y1=-90000000;//85051128;
    
var y290000000;//85051128;
    
var y1cons=0;
    var 
y2cons=32;
    var 
yconsdel=0;
    var 
n=0;
    var 
xlinetest=0;
    var 
ylinetest=0;
    var 
test=0;
    var 
z=curzoomkv-1;
    while(
z>=0)
    {
      
xdel=Math.round((x1+x2)/2);
      
ydel=Math.round((y1+y2)/2);
      
test=Math.pow(2,z);
      
xlinetest=xline&test;
      
ylinetest=yline&test;
      if(
xlinetest>0){x1=xdel+1}
      else           {
x2=xdel  }
      if(
ylinetest>0){y1=ydel+1;y1cons=yconsdel}
      else           {
y2=ydel  ;y2cons=yconsdel}
      
z--;
      
n++;
    }
    if((
x>=x1)&&(x<=x2)&&(y>=y1)&&(y<=y2))return 1;
    else                                  return 
0;
}

TileTale.prototype.getZTile=function (x,y,zoom)
{
    var 
xdel=0;
    var 
ydel=0;
    var 
xline=0;
    var 
yline=0;
    var 
x1=-180000000;
    var 
x2180000000;
    var 
y1=-90000000;//85051128;
    
var y290000000;//85051128;
    //var y1=-85051128;
    //var y2= 85051128;
    
var y1cons=0;
    var 
y2cons=32;
    var 
yconsdel=0;
    var 
n=0;
    var 
z=zoom-1;
    while(
z>=0)
    {
         
xdel=Math.round((x1+x2)/2);
         
ydel=Math.round((y1+y2)/2);
         if(
x<=xdel){x2=xdel  ;xline=xline*2;}
         else       {
x1=xdel+1;xline=xline*2+1;}
         if(
y<=ydel){y2=ydel  ;y2cons=yconsdel;yline=yline*2  ;}
         else       {
y1=ydel+1;y1cons=yconsdel;yline=yline*2+1;}
         
z--;
         
n++
         

    }
    return {
x:xline,y:yline}
}

TileTale.prototype.retcode = function (xline,yline,curzoomkv)
{
var 
xparam=0;
var 
yparam=0;
var 
test=0;
var 
xlinetest=0;
var 
ylinetest=0;
var 
line='';
var 
z=curzoomkv-1;
while(
z>=0)
{
  
test=Math.pow(2,z);
  
xlinetest=xline&test;
  
ylinetest=yline&test;  
  if(
xlinetest>0){xparam=2}
  else           {
xparam=0}
  if(
ylinetest>0){yparam=1}
  else           {
yparam=0}
  
  
/* */
  
if( xparam &&  yparam)linepart='0';
  if( 
xparam && !yparam)linepart='1';
  if(!
xparam && !yparam)linepart='2';
  if(!
xparam &&  yparam)linepart='3';
  
  
line=line+linepart;
  
z--;
}
return 
line;
}






TileTale.prototype.getTiles= function (x1point,y1point,x2point,y2point,zoompoint)
{
    var 
require_block=[];
    
//    this.thisBounds={x1:x1point,x2:x2point,y1:y1point,y2:y2point,zoom:zoompoint};
    
    //zoom+=this.ZoomOffset
    //zoompoint--;
    
    
x1point=Math.ceil(x1point*ZM_FACTOR);
    
y1point=Math.ceil(y1point*ZM_FACTOR);
    
x2point=Math.ceil(x2point*ZM_FACTOR);
    
y2point=Math.ceil(y2point*ZM_FACTOR);
    
    
    
zoompoint=zoompoint-1;   
    if(
x1point<-180000000){x1point=-180000000}
    if(
x2point<-180000000){x2point=-180000000}
    if(
x1point180000000){x1point=180000000}
    if(
x2point180000000){x2point=180000000}
    if(
y1point<-85051128) {y1point=-85051128}
    if(
y2point<-85051128) {y2point=-85051128}
    if(
y1point85051128) {y1point=85051128}
    if(
y2point85051128) {y2point=85051128}
    
    
    var 
outar=this.getZTile(x1point,y1point,zoompoint);
    
    var 
xline=outar.x;
    var 
yline=outar.y;
    var 
zmax=Math.pow(2,zoompoint)-1;
    var 
vres  =0;
    var 
xsdvig=0;
    var 
xlinet=xline;
    var 
ylinet=yline;
    
    while(
vres!=1)
    {
        
vres=this.checkPoint(x2point,y1point,xlinet,ylinet,zoompoint);    
        
xsdvig++;
        
xlinet=xlinet+1;
        if(
xlinet>zmax){xlinet=0}
    }
    if(
xlinet==zmax)
     {
xsdvig=1};
    
vres=0;
    var 
ysdvig=0;
    
xlinet=xline;
    
ylinet=yline;
    while(
vres!=1)
    {
        
vres=this.checkPoint(x1point,y2point,xlinet,ylinet,zoompoint);
        
ysdvig++;
        
ylinet=ylinet+1;
        if(
ylinet>zmax){ylinet=0}
    }
    if(
ylinet==zmax)
     {
ysdvig=1};
    var 
temp='';
    var 
newtemp='';
    var 
ylinesave=yline;
    var 
ysdvigsave=ysdvig;
    while(
xsdvig>0)
    {
        while(
ysdvig>0)
        {
            
temp=''+this.retcode(xline,yline,zoompoint);
            
temp=temp.substring(0,16);
            var 
lineleng=0;
            var 
newtemp='';
            while(
lineleng<temp.length)
            {
              
newtemp=newtemp+"/"+temp.substring(lineleng,lineleng+3);
              
lineleng=lineleng+3;
            }
             
newtemp=newtemp.substr(1,newtemp.length-1);
             
newtemp=newtemp;
             
xml_url=newtemp;
             
require_block.push({addr:temp,z:xml_url,x:xline,y:yline,zoom:zoompoint});
             
ysdvig--;yline++;
            if(
yline>zmax){yline=0}
        }
        
yline=ylinesave;
        
ysdvig=ysdvigsave;
        
xsdvig--;
        
xline++;
        if(
xline>zmax){xline=0}
    }
    return 
require_block;
}

TileTale.prototype.getTilesVisibleSet = function (){
    var 
b=this.getBounds();
    var 
visibleset=this.getTiles(b.x1,b.y1,b.x2,b.y2,zoom);
    var 
outset=array();
    var 
layerSet=this.layerSet.slice(0); 
    while( (
rq=visibleset.shift()) ){
        
rq.layers=layerSet.slice(0);
        var 
gotarrn=rq.addr;
        
        if(
this.nav_block_index[gotarrn])
         for(
i in layerSet)
          if(
this.nav_block_index[gotarrn][i])
          {
           
rq.layers[i]=0;
           
outset.push(this.nav_block_index[gotarrn][i]);
          }
        
        var 
a1=String(gotarrn);
        var 
stop1=0;
        var 
stop2=0;
        var 
l=a1.length;
        for(
ii=1;ii<l;ii++)
        {
          var 
ind=a1.slice(0,ii);
          var 
f=0;   
          if(
this.nav_block_index[ind])
          {
               
f=1;
               for(
li in layerSet)
               if(
rq.layers[li])
               {
                if(
this.nav_block_index[ind][li])   
                 if(
this.nav_block_index[ind][li]['final'])
                 {
                  
rq.layers[li]=0;
                 }
               }
          }
        }  
    }
}


TileTale.prototype.TileRelationsBroker = function (RB)
{
    
//first run layer slice
     
var req=[];
     var 
layerSet=this.layerSet.slice(0); 
     while( (
rq=RB.shift()) )
     { 
        
rq.layers=layerSet.slice(0);
        var 
i=0;
        var 
gotarrn=rq.addr;
        if(
this.nav_block_index[gotarrn])
         for(
i in layerSet)
          if(
this.nav_block_index[gotarrn][i])
           
rq.layers[i]=0;
        
        var 
a1=String(gotarrn);
        var 
stop1=0;
        var 
stop2=0;
        var 
l=a1.length;
        for(
ii=1;ii<l;ii++)
        {
          var 
ind=a1.slice(0,ii);
          var 
f=0;   
          if(
this.nav_block_index[ind])
          {
               
f=1;
               for(
li in layerSet)
               if(
rq.layers[li])
               {
                if(
this.nav_block_index[ind][li])   
                 if(
this.nav_block_index[ind][li]['final'])
                 {
                  
rq.layers[li]=0;
                 }
               }
          }
        }
        
        var 
limore='';
        
rq.inLayers=0;
        for(
i in rq.layers)
        {
           if(
rq.layers[i]==i){limore+=i+'-';
            
rq.inLayers++;
           }
        }
        if(
limore)
        {
         
rq.layerLine=limore;
         
rq.DS     =this.assignDataCenter(rq);
         
rq.addr_to this.createLineRequest(rq);
         
//if(!tile_isset(this.NavRequestsAjaxian[rq.addr_to]))
         
req[gotarrn]=(rq);
        }
       
// break;
     
}
    
    
     return 
req;
}

TileTale.prototype.sliceBuyLayer=function(blocks){
    var 
ret=[];
    var 
i=0;
    var 
rq=0;
    var 
ind=0;
    var 
MAX_LAYERS_PER_REQUEST=2;
    
//while( (rq=blocks.shift()) ){
    
for( ind in blocks )
    if(
blocks[ind] )
    {
      
irq=blocks[ind];
      
      if(
irq.inLayers>MAX_LAYERS_PER_REQUEST){
        for(
i=0;i<irq.inLayers;i+=MAX_LAYERS_PER_REQUEST){
            var 
tmp={addr:irq.addr,z:irq.z,x:irq.x,y:irq.y,zoom:irq.zoom};
            
tmp.DS=irq.DS;
            var 
limore='';
            var 
inLayers=0;
            var 
sliced=0;
            var 
ini=0;
            for(
ini in irq.layers)
            {
               if(
irq.layers[ini]==ini){
                if(
inLayers>=i)
                {
                 
limore+=ini+'-';
                 
sliced++;
                 if(
sliced>=MAX_LAYERS_PER_REQUEST)break;
                }
                
inLayers++;
                
               }
            }
            
tmp.layerLine=limore;
            
tmp.addr_to this.createLineRequest(tmp);
            
ret.push(tmp);
        }
      }else 
ret.push(irq);
    }
    return 
ret;
}

TileTale.prototype.performRequire=function(require_block)
{
    var 
i=0;
    var 
gotarrn=0;
    
    
    var 
clientRequests=this.TileRelationsBroker(require_block);
    var 
cnt=0;
    for(
i in clientRequests)if(clientRequests[i])cnt++;
    
    
this.queryRender();
    
    if(
cnt>0){
        
//if(window.console && console)
        // console.log(cnt+" tiles in");
        
        
clientRequests=this.clearNavRequestTimeouts(clientRequests);
        
        
clientRequests=this.sliceBuyLayer(clientRequests);
        var 
cnt=0;
        for(
i in clientRequests)if(clientRequests[i])cnt++;
        
        
//if(window.console && console)
        // console.log(cnt+" tiles after");
        
        
if(!this.allowBlockRequests){
            while( (
rq=clientRequests.shift()) )
            {
                        
              
this.callRequestTimer(rq,i);
              
i++;
            }
        }
        else
        {
            
this.blockRequest(clientRequests);        
        }
    }
    
    
this.queryRender();    
}

TileTale.prototype.clearNavRequestTimeouts = function (active)
{
 var 
idx=0;
 
this.NowRequestingCnt=0;
 var 
ii;
 
//clear timeouts
 
 //while( (i = this.NavRequestsTimes.shift()) )
 
for(ii in this.NavRequestsTimes )
 {
    var 
i=this.NavRequestsTimes.ii;
    
idx++;
    var 
del=0;
    if(!
active[i.id])
    {
        if(!(
i.count--))
        {
            
clearTimeout(i.tm);
            
idx--;
            
del=1;
        }
    }else
    {
delete(active[i.id]);
    }
 }
 if(
idx==0)
 
this.NavRequestsTimes=[];
 
 
idx=0;
 
//clear transports
 //while( (i=this.NavRequestsAjaxian.shift()) )
 
for(ii in this.NavRequestsAjaxian )
 {
    var 
i=this.NavRequestsAjaxian[ii];
    var 
del=0;
    if(!
active[i.id])
    {
     if(!(
i.rq.count--))
     {
      
del=1;
      
i.rq.ajax.transport.abort();
      
delete (i);
     }
    }else
    {
        
delete(active[i.id]);
        
idx++;
    }
 }
 if(
idx==0)
 
this.NavRequestsAjaxian=[];
 
 return 
active;
}

TileTale.prototype.callRequestTimer = function (rq,i)
{
    var 
d=0;
    if(
i>0)d=50;else d=0;
    var 
topobj=this;
    
this.NavRequestsTimes[rq.addr]={id:rq.addr,count:1,tm:(setTimeout(function(){
          
delete topobj.NavRequestsTimes[rq.addr];
          
topobj.request_map_block(rq);  
          },
50+topobj.requestTimeShift*i+d))};  
}

TileTale.prototype.createLineRequest = function (rq){
    return 
rq.layerLine+'l'+rq.z;
}


window.tile__mergepos = function (a,b)
{
    var 
l1=a.length;
    var 
l2=b.length;
    var 
i=0;
    var 
l=l1>l2?l2:l1;
    for(
i=0;i<l;i++){
        if(
a[i]!=b[i])return i;
    }
    return 
0;
}

var 
js_natsortType=1;
var 
js_natsortLimit=256;
function 
js_natsort(a,b) { // case sensitive
    
        
if( js_natsortType == ) { // lower cases between the upper cases
            
var replaceArray= new Array('0','1','2','3','4','5','6','7','8','9','A','a','B','b','C','c','D','d','E','e','F','f','G','g','H','h','I','i','J','j','K','k','L','l','M','m','N','n','O','o','P','p','Q','q','R','r','S','s','T','t','U','u','V','v','W','w','X','x','Y','y','Z','z','_');
        } else if( 
js_natsortType == ) { // lower cases after all upper cases
            
var replaceArray= new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_');
        }
        
        
a.toString();
        if( 
a.length js_natsortLimit a.substr(0,js_natsortLimit);
        
a.replace(/\W/g'_');
        var 
aArr a.split('');
        for( var 
i=0replaceArray.lengthi++ ) {
            for( var 
k=0aArr.lengthk++ ) {
                if( 
aArr[k] == replaceArray[i] ) {
                    if( 
10 aArr[k] = parseInt(i);
                    else 
aArr[k] = i.toString();
                }
            }
        }
        
        
b.toString(); 
        if( 
b.length js_natsortLimit b.substr(0,js_natsortLimit);
        
b.replace(/\W/g'_');
        var 
bArr b.split('');
        for( var 
i=0replaceArray.lengthi++ ) {
            for( var 
k=0bArr.lengthk++ ) {
                if( 
bArr[k] == replaceArray[i] ) {
                    if( 
10 bArr[k] = parseInt(i);
                    else 
bArr[k] = i.toString();
                }
            }
        }
        
        
aArr js_natsort_combineInt(aArr);
        
bArr js_natsort_combineInt(bArr);
        for( var 
i=0aArr.lengthi++ ) {
            if( 
aArr[i] != bArr[i] ) {
                if( 
typeof aArr[i] == typeof bArr[i] ) {
                    return (
aArr[i]==bArr[i]) ? : (aArr[i]>bArr[i]) ? : -1;
                } else {
                    if( 
typeof aArr[i] == 'string' && typeof bArr[i] == 'number' ) return 1;
                    if( 
typeof aArr[i] == 'number' && typeof bArr[i] == 'string' ) return -1;
                }
            }  
        }
        
        return 
0;
    }
    
        
// natsort helper - js_natsort_combineInt
    
function js_natsort_combineInt(array) {
        
        for( var 
i=0< array.lengthi++ ) {
            if( 
typeof array[i] == 'number' && typeof array[i+1] == 'number' ) {
                var 
num = array[i].toString() + array[i+1].toString();
                array[
i] = parseInt(num);
                array = 
js_natsort_delArrayEl(array, i+1);
                
js_natsort_combineInt(array);
                break;
            }
        }
        
        while( array.
length js_natsortLimit void array.push('00');
        return array;
        
    }
    
    
// remove element from array
    
function js_natsort_delArrayEl(array, element) {
        for( var 
element< array.lengthi++ ) {
            array[
i] = array[i+1];
        }
        array.
pop();
        return array;
    }

    
// is int
    
function isInt(x) {
        var 
parseInt(x);
        if (
isNaN(y)) return false;
        return 
== && x.toString() == y.toString();
    } 


TileTale.prototype.blockRequest = function (rq_line)
{
 var 
addr='';
 var 
cnt=0;
 var 
proxy='';
 var 
callobj=this;
 var 
setarray=[];
 for(
i in rq_line)
 {
   
   var 
rq=rq_line[i];
   if(!
proxy)proxy=rq.DS;
   var 
gotarrn=rq.addr;
   var 
addr_to=rq.addr_to;
   
//addr+=addr_to+";";
   
setarray.push(addr_to);
   
cnt++;
 }
 if(
cnt==0)return;
 var 
sortgeneration=0;
 var 
ts1=this.microtime();
 
//if(window.XMLHttpRequest)
 
setarray.sort();
   
 
//tile__natsort(setarray);
 //while(1)
 
{
    var 
insort=function(){
        
addr='';
        var 
preaddr='';
        var 
aline;
        var 
acnt=0;
        var 
thisrqline=[];
        while( (
aline=setarray.shift()) )
        {
           if(!
preaddr)preaddr=aline;
           else{
            var 
p=tile__mergepos(preaddr,aline)
            
preaddr=aline;
            
aline=aline.substr(p,aline.length-p);
            if(
p>0)aline=p+"~"+aline;
           }
           
addr+=aline+";";
           
           for(
i in rq_line){
            if(
rq_line[i].addr_to==aline){
             
thisrqline.push(rq_line[i]);
             
delete rq_line[i];
             break;
            }
           }
           
acnt++;
           if(
acnt>=callobj.zBurstLimit)
            break;
        }
        if(!
addr || !acnt)
         return 
false;
        
sortgeneration++;
        var 
startTime=callobj.microtime();
        var 
ajaxreq={count:acnt,ajax:callobj.AjaxRequest(proxy+addr,
                       {
                        
method:'get',encoding:"UTF-8",asynchronous:true,
                        
onFail    :function()    {callobj.stopRequesting(thisrqline)},
                        
onComplete:function(data){callobj.stopRequesting(thisrqline);callobj.loadNavBlock(data,thisrqline,startTime);}
                        },
sortgeneration)};
        
callobj.startRequesting(thisrqline);
        for(
i in thisrqline){   
          var 
rq=thisrqline[i];
          
callobj.NavRequestsAjaxian[rq.addr_to]={id:rq.addr,rq:ajaxreq};
        }
        return 
true;
    }
    var 
acnt=0;
    while(
insort())
    {
        
        
acnt++;
    }
    
//if(acnt>0)
    //if(window.console && console)
    // console.log(acnt+" request out");
 
}
 
}

TileTale.prototype.request_map_block = function (rq)
{
 var 
gotarrn=rq.addr;
 
//delete this.NavRequestsTimes[gotarrn]=0;
 
var addr_to=rq.addr_to;
 if(!
this.NavRequestsAjaxian[addr_to])
 {
  var 
inrq={0:rq};
  
this.startRequesting(inrq);
  var 
callobj=this;
  var 
startTime=callobj.microtime();
  var 
rqobj={id:gotarrn,rq:{count:1,timein:this.microtime(),
                              
ajax:this.AjaxRequest(proxy+addr_to,
                                                   {
                                                    
method:'get',encoding:"UTF-8",asynchronous:true,
                                                    
onFail    :function()    {callobj.stopRequesting(inrq)},
                                                    
onComplete:function(data){callobj.stopRequesting(inrq);callobj.loadNavBlock(data,rq,startTime);}
                                                    })}};
  
this.NavRequestsAjaxian[addr_to]=rqobj;
 }
 else
 {
    if(
window.console)
     
console.log(addr_to+" is allready proccessing");
 }
}

TileTale.prototype.startRequesting = function (rqs)
{
  for( 
i in rqs )
  {
    var 
rq=rqs[i];
    
this.NowRequesting(1);
    var 
addr_to=rq.addr_to;
    
this.NavRequestsAjaxian[addr_to]=0;
    
delete this.NavRequestsAjaxian[addr_to];
  }
}

TileTale.prototype.stopRequesting = function (rqs)
{
  for( 
i in rqs )
  {
    var 
rq=rqs[i];
    
this.NowRequesting(-1);
    var 
addr_to=rq.addr_to;
    
this.NavRequestsAjaxian[addr_to]=0;
    
delete this.NavRequestsAjaxian[addr_to];
  }
}




TileTale.prototype.NowRequesting = function (a)
{
    
this.NowRequestingCnt+=a;
    
this.onRequestingChange(this.NowRequestingCnt);
}

TileTale.prototype.AjaxRequest = function (addr,params)
{
    
alert("implement your own!")
}

TileTale.prototype.decodeNavBlock = function (data,uri,gotarrn)
{
    return 
data;
}

/**
 * производит вставку обьекта в заданый блок слоя
 * сюда мы только передаем данные обьекта, который драйвиться менеджером слоя
 * @param object - обьект
 * @param layer - слой
 * @gotarrn - идентификатор слоя( 0 для автоопределения)
 **/ 
TileTale.prototype.insertObject = function (object,layer,gotarrn)
{
    if(!
gotarrn)
     
gotarrn='';
    
block=gotarrn
}

TileTale.prototype.preprocessData = function (dataline,request)
{
    if(!
dataline.mapreq)return {mapreq:{0:dataline}};
    else                return 
dataline;
}

TileTale.prototype.loadNavBlock = function (data,request,startTime){
    var 
_this=this;
    
setTimeout(function(){
        
_this.injectDirectObject=0;
        
_this._in_loadNavBlock(data,request,startTime)
        
_this.injectDirectObject=1;
    },
1);
}

TileTale.prototype._in_loadNavBlock = function (data,request,AstartTime)
{
    
//forlayers
    
var tilethis=this;
    var 
loadingStart=this.microtime();
    
data=this.preprocessData(data,request);
    var 
closure=function()
    {
        var 
undone=0;
        var 
i;
        for(
i in data.mapreq)
        if(
data.mapreq[i])
        {
          try{
          
tilethis.loadDataLine(tilethis.decodeNavBlock(data.mapreq[i],request));
          }catch(
e)
          {
            if(
window.console)
             
console.log(e);
          }
          
delete data.mapreq[i];
         
          
undone=1;
          break;
        }
        
//tilethis.restackObjects();
        
if(undone){
         
//setTimeout(function(){closure()},0);
         
closure();
        }
        else{
         
tilethis.queryRender();
         if(
window.console)
          
console.log("tile loadparsed in",(tilethis.microtime()-loadingStart)," load in",(tilethis.microtime()-AstartTime));
        }
    }
    
    if(
this.config_TimeredLoad){
        
closure();
    }
    else
    {
        for( 
i in data.mapreq ){
         
this.loadDataLine(this.decodeNavBlock(data.mapreq[i],request));     
        }
        
tilethis.queryRender();
    }
}

function 
getRandomArbitary(minmax)
{
  return 
Math.random() * (max min) + min;
}

TileTale.prototype.loadDataLine = function (data,request)
{
    var 
i;
    var 
bounds=this.getBounds();
    
this.newGeneration();
    for(
i in data)
    {
        var 
layer=data[i];
        var 
layer_id=parseInt(layer.layer);
        var 
l1cnt=0;
        var 
l2cnt=0;
        var 
ltcnt=0;
        {
           var 
block=layer.tile;
           var 
bzoom=block.length;
           var 
inblock=layer.intile;
           
           if(
this._tiledebug)
           {
                var 
polygon = new YMaps.Polyline([
                new 
YMaps.GeoPoint(layer.area.x1/ZM_FACTOR,layer.area.y1/ZM_FACTOR),
                new 
YMaps.GeoPoint(layer.area.x1/ZM_FACTOR,layer.area.y2/ZM_FACTOR),
                new 
YMaps.GeoPoint(layer.area.x2/ZM_FACTOR,layer.area.y2/ZM_FACTOR),
                new 
YMaps.GeoPoint(layer.area.x2/ZM_FACTOR,layer.area.y1/ZM_FACTOR)
                ], {
                
style"polygon#Example",
                
hasHint1,
                
hasBalloon1
                
});
                
                
polygon.name block;
                
polygon.description block
                
                
this.map.worker.api.addOverlay(polygon);
           }
           
           
           
           if(!
this.nav_block_index[block])
           {
            
this.nav_block_index[block]=[];
            
this.nav_block_index[block]['area']={x1:layer.area.x1/ZM_FACTOR,
                                                 
x2:layer.area.x2/ZM_FACTOR,
                                                 
y1:layer.area.y1/ZM_FACTOR,
                                                 
y2:layer.area.y2/ZM_FACTOR};
            
this.nav_block_index[block]['zoom']=block.length;
           }
           if(!
this.nav_block_index[block][layer_id])
           {
            
this.nav_block_index[block][layer_id]=[];
            
this.nav_block_index[block][layer_id].objects=[];
           }
           
layer.isFinal=parseInt(layer.isFinal);
           
this.nav_block_index[block][layer_id]['final']=layer.isFinal;
           
           
/* * /
            if(window.console && console)
             if(layer.isFinal)
               console.log("final level for l:"+layer_id+" at "+block);
             else
               console.log("still level for l:"+layer_id+" at "+block);
           /* */  
           
var objects=layer.objects;
           
           var 
layerlen=block.length;
           for(
x in objects)
           {
             var 
object=objects[x];
             if(
this._collapceCounter)
               
object.CNT=1;
               
             var 
idkey=(object['ID_MAP_OBJECT']);
             
ltcnt=Math.max(ltcnt,object['CNT']);
             
             
object.CNT=parseFloat(object.CNT);
             
             if(!
this.nav_objects[idkey])
             {
                var 
obj=this.injectObject(object,layer_id,x+layerlen*layer.objcnt);
                if(!
obj){
                    continue;
                }
                
obj.maxKnownZoom=bzoom;
                
                
l1cnt++;
             }
             else
             {
                
l2cnt++;
                var 
obj=this.nav_objects[idkey];
                var 
newcnt=Math.min(this.nav_objects[idkey].storedCapacity,
                                                                
object.CNT);
                if(
newcnt!=this.nav_objects[idkey].storedCapacity){
                    
this.nav_objects[idkey].generation=this.currentGeneration();
                }
                
this.nav_objects[idkey].storedCapacity=newcnt;
                
this.nav_objects[idkey].reStack=1;
                
                
obj.maxKnownZoom=Math.min(obj.maxKnownZoom,bzoom);
                
                
object=this.nav_objects[idkey];
                if(!
object.layers[layer_id])
                 
this.nav_objects[idkey].layers[layer_id]=(layer_id); 
             }
             
this.nav_objects[idkey].lasttile=block;
             
             if(
this.nav_block_index[block] && this.nav_block_index[block][layer_id] && this.nav_block_index[block][layer_id].objects)   
               
this.nav_block_index[block][layer_id].objects[idkey]=idkey;  
           }
           
           if(
block!=inblock)
           {
             var 
l1=inblock.length;
             var 
ii=0;
             
             var 
layerinto=[];
             
layerinto['final']=1;
             
layerinto['dummy']=1;
             
             for(
i=block.length+1;i<=l1;i++)
             {
                var 
nameblock=inblock.slice(0,i);
                if(!(
this.nav_block_index[nameblock] && this.nav_block_index[nameblock][layer_id])){
                    if(!
this.nav_block_index[nameblock])
                     
this.nav_block_index[nameblock]=[];
                    if(!
this.nav_block_index[nameblock][layer_id])
                     
this.nav_block_index[nameblock][layer_id]=[]; 
                    
this.nav_block_index[nameblock][layer_id]=layerinto;
                }
             }
           }
           
        }
        
//if(window.console && console)
        // console.log(layer.tile+"/"+layer.depth+":l"+layer_id+" loaded with "+l1cnt+"/"+l2cnt+" t"+ltcnt+" >> "+layer.objcnt+"//"+layer.totalcnt);
    
}

    
//this.queryRefresh();
    
return true;
}

TileTale.prototype.objectInLayer = function (obj,l)
{
    for(
i in obj.layers)
    {
     if(
i==l)return true;
    }
    return 
false
}

TileTale.prototype.queryRender=function()
{
    var 
tile=this;
        
    
//if(this.ts_queryRender2)
     
clearTimeout(this.ts_queryRender2);
    
//this.ts_queryRender2=setTimeout(function(){tile.in_queryRender()},50);
    
    //if(this.ts_queryRender)return;
    
    //if(this.ts_queryRender)
     
clearTimeout(this.ts_queryRender);

    
this.ts_queryRender=setTimeout(function(){
        
tile.in_queryRender(1)
    },
100);
}

TileTale.prototype.hideAll = function(a){
    var 
tileobjects=this.nav_objects;
    var 
deleteset=[];
    for(
i in this.nav_objects){
        if(
tileobjects[i] && tileobjects[i].shown){
            
this.hideObject(i);            
        }
    }    
    
this.newGeneration();
}

TileTale.prototype.DimensionError = function (){
    if(
window.console)
     
console.log("dimension error");
    
this.hideAll();
    return 
false;
}

TileTale.prototype.in_queryRender=function(force)
{
    
clearTimeout(this.refreshTimer);
    
clearTimeout(this.ts_queryRender);
    
clearTimeout(this.ts_queryRender2);
    
//if(this.force)
    //    this.restackObjects();
        
    
var starttime=this.microtime();
    var 
bounds=this.getBounds();
    var 
tileobjects=this.nav_objects;
    var 
blockindex =this.nav_block_index;
    var 
_this=this;
    var 
tilethis=this;
    var 
cnt=0;
    var 
vcnt=0;
    var 
delta=tilethis.getStackableDelta();
    if(!
delta)return this.DimensionError();
    var 
v2cnt=0;
    var 
ingen=this.currentGeneration();

    
this.lastRenderZoom=bounds.zoom;
    
    var 
workingset=this.cluster.setup(bounds.x1,bounds.y1,bounds.x2,bounds.y2,bounds.zoom,ingen);
    var 
realbounds=this.cluster.getBounds();
    
    var 
pushobjset=[];
    var 
pushObject = function(iobject,fullpass){
        if(
pushobjset[iobject])return;
        
pushobjset[iobject]=1;
        var 
obj=tileobjects[iobject];
        if(
fullpass){
          
_this.cluster.push(obj);
          
cnt++;
        }
        else{
            
// var dim=obj.Bounding;
             //if(!dim)dim=obj.dim;
             
var dimw=0;//dim.w;
             
var dimh=0;//dim.h;
             
if(((obj.LATITUDE +dimh)>realbounds.y1 && (obj.LATITUDE -dimh)<realbounds.y2 &&
                 (
obj.LONGITUDE+dimw)>realbounds.x1 && (obj.LONGITUDE-dimw)<realbounds.x2)){
                 
_this.cluster.push(obj);
                 
cnt++;
             }
        }
        
        if(
obj.shown)
            
v2cnt++;
    }
    
    var 
allowzoomdelta=1;
    if(
bounds.zoom<9)allowzoomdelta=2;
    if(
bounds.zoom<6)allowzoomdelta=4;
    var 
QRprepare=function(){
        
        for( 
i in tilethis.dirrectObjects){
           
pushObject(i,false); 
        }
        
        var 
block;
        var 
lset=tilethis.layerSet.slice(0);
        for(
block in  blockindex){
          var 
thisblock=blockindex[block];
          var 
area=thisblock['area'];
          var 
zoom=thisblock['zoom'];
          if(
zoom<=(bounds.zoom+allowzoomdelta)){
            
//check area
            
var hit=area.x1<realbounds.x2 && area.x2>realbounds.x1 &&
                    
area.y1<realbounds.y2 && area.y2>realbounds.y1;
            if(
hit){
                var 
fullhit=area.x1>=realbounds.x1 && area.x2<=realbounds.x2 &&
                            
area.y1>=realbounds.y1 && area.y2<=realbounds.y2;
                
                var 
l=0;
                for( 
l in lset )if(thisblock[l]){
                    var 
linnerthisblock[l].objects;
                    for(
i in linner){
                        
pushObject(linner[i],fullhit);
                    }
                }
            }
            
          }
        }
    }
    
    if(
workingset.update.length){
        
this.cluster.start(workingset);
        
QRprepare();
        
this.cluster.end();
    }
    
this.cluster.setVisibleSet();
    var 
torender=this.cluster.getRender(tilethis.LIMIT_OBJECTS);
    
rcnt=this.cluster.renderCount;
    var 
updateset=this.cluster.getUpdateset(tilethis.LIMIT_OBJECTS);
    
    
    var 
todelete=[];
    var 
deleted=0;
    var 
QRhintdeleted=function(){
        for(
ii in tilethis.visiblePipeline)
        {
            
i=ii;//tilethis.visiblePipeline[ii];
            
if(&& tilethis.visiblePipeline[i])
             if(!
torender[i] || typeof(torender[i])=='undefined'){
                
tilethis.hideObject(i);
                
deleted++;
             }
    }}
        
    
QRhintdeleted();

    var 
newcnt=0;
    var 
rencnt=0;
    
    
    var 
QRhintrender=function(){
        for(
ii in updateset)
        {
            var 
f=0;
            
i=updateset[ii];
            
//if(updateset[i])
            
{
                
tilethis.showObject(i);
                
vcnt++;
            }
        }
    }
    
QRhintrender();
    
    
this.render_objects=torender;//.slice(0);
    
    
if(window.console && console)
    {
     var 
endtime=this.microtime();
     var 
rrcnttilethis.realrender.length;
     
console.log("currently("+ingen+") visible:"+cnt+"-"+
                 
this.cluster.renderCount+"/"+this.cluster.renderShown+"/"+this.cluster.renderUpdate+"("+vcnt+"), deleted:"+deleted+" | in "+(endtime-starttime));
    }
    
    
this.ts_queryRender=0;
    
    
//if(vcnt)//newcnt || rencnt)
    
this.queryRefresh();
     
    if(
vcnt){
        
//setTimeout(function(){tilethis.queryRender();},300);
    
}else this.cluster.finishTurn();
    
    return 
true;
}

TileTale.prototype.stackedTween=function(_inset)
{
    var 
cnt=0;
    var 
tilethis=this;
    var 
i;
    for( 
i in this.nav_objects){
        var 
iobj=this.nav_objects[i];
        for(
j in this.new_objects)
         if(
j>i){
           var 
jobj=this.nav_objects[i];
           if(
iobj.LATITUDE==jobj.LATITUDE &&
              
iobj.LONGITUDE==jobj.LONGITUDE)
             
this.setstackedTween(iobj,jobj);
         }
    }
   return 
resultset;
}

TileTale.prototype.setstackedTween=function(iobj,jobj){
    
}

TileTale.prototype.queryRefresh=function()
{
    if(
this.refreshTimer)
      
clearTimeout(this.refreshTimer);
    var 
tile=this;
    
this.refreshTimer=setTimeout(function(){tile.tickRender()},this.RENDER_TIME_STEP);
}

TileTale.prototype.tickRender=function()
{
    
clearTimeout(this.refreshTimer);
    
this.refreshTimer=0;
    var 
cnt=0;
    var 
ticktest=0;
    var 
rr=this.renderPipeline;
    var 
limit=this.ZTILE_RENDER_LIMIT;
    var 
tilethis=this;
    var 
i;
    var 
haveobjects=0;
    for( 
i in rr ){
        
haveobjects=1;
        break;
    }
    
    var 
tickRenderFlow=function(){
    
//while( (ind = rr.shift()) )
    
for( i in rr ){
        var 
cmd=rr[i];
        
ticktest++;
       
// console.log(i,cmd);
        
cmd();
        
cnt++;
        
delete rr[i];
        if(
cnt>limit)
         break;
    }}
    if(
haveobjects){
        
this.map.openMapTransaction();
        
tickRenderFlow();
        
this.map.closeMapTransaction();
    }
    if(
cnt){
     
this.chargeAfterRender=1;   
     
tilethis.queryRefresh();
    }
    else{
        
this.renderPipeline=[];
        if(
this.chargeAfterRender)
         
this.queryRender();
        
this.chargeAfterRender=0
    }
    return 
cnt;
}

TileTale.prototype.pushRender = function(obj,action){
    
this.renderPipeline[obj.ID_MAP_OBJECT]=action;
    
this.queryRefresh();
}

TileTale.prototype.hideObject = function (ind)
{
   var 
bounds=this.getBounds();
   var 
object=this.nav_objects[ind];
   if(object)
   {
     var 
_this=this;
     
this.pushRender(object,function(){
        
_this.visiblePipeline[ind]=0;
        
object.shown=0;
        
_this.layerCall(object.layers,object,'hide');
    });     
   }
}



TileTale.prototype.resetObjects = function ()
{
   
this.chargeAfterRender=0;
   while(
this.tickRender()){
    
this.chargeAfterRender=0;
    
//nop
   
}
   
   
this.map.openMapTransaction();

   for(
ind in this.nav_objects)
   if(
ind && this.nav_objects[ind])
   {   
     var 
object=this.nav_objects[ind];
     var 
_this=this;
     
_this.visiblePipeline[ind]=0;
     
_this.layerCall(object.layers,object,'reset');
     
this.nav_objects[ind]=object;
   }
   
   
this.map.closeMapTransaction(); 
   
   
   
this.restackObjects();
   
this.newGeneration();
}

TileTale.prototype.showObject = function (ind)
{
    var 
object=this.nav_objects[ind];
    var 
_this=this;
     
_this.visiblePipeline[ind]=1;
    
this.pushRender(object,function(){
        
object.shown=1;
       
        
_this.layerCall(object.layers,object,'show');
    });     
}

TileTale.prototype.restackObjects = function ()
{
   for(
ind in this.nav_objects)
   if(
ind && this.nav_objects[ind])
   {   
     var 
object=this.nav_objects[ind];
     
object.stackCNT=0;
     
object.stackedBefore=0;
     
object.stacked=[];
     
this.nav_objects[ind]=object;
   }
}

TileTale.prototype.layerCall = function (layerlist,object,func)
{
    try{
        
//var object=0;
        
for(l in layerlist)
        { 
         if(
this.layerEvents[l])
          for(
i in this.layerEvents[l])
          {
            var 
f=this.layerEvents[l][i]['functions'][func];
            if(
f)
             
object=f(this.layerEvents[l][i]['meta'],object,l,this.map,this);
          }
        }
    }catch(
e)
    {
        if(
window.console)
         
console.log("Zshow error:",e);
    }
    return 
object;
}

TileTale.prototype.assignLayer = function(layer,meta,functionlist)
{
    if(!
layer)return;
    if(!
this.layerEvents[layer])
     
this.layerEvents[layer]=[];
    
this.layerEvents[layer].push({'meta':meta,'functions':functionlist
                                 
//'show':show,'hide':hide,'apply':apply
                                 
}); 
}

TileTale.prototype.setObject = function(object)
{
    
this.nav_objects[object.idkey]=object;
}


TileTale.prototype.getMinViewDimensions = function ()
{
    return 
this.map.getMinViewDimensions();
}



/*** ПЕРЕГРУЖАЕМЫЕ ФУНКЦИИ ****/

TileTale.prototype.getStackableDelta = function ()
{
    var 
bounds=this.thisBounds;
    
    var 
dim=this.getMinViewDimensions();
    if(
dim<100)return false;
    
//dim=16/dim;
    
    
var dx=Math.abs(bounds.x2-bounds.x1);
    var 
dy=Math.abs(bounds.y2-bounds.y1);
    if(
dx>dy)dw=dy;else dw=dx;
    
    return (
dw/dim);
    
    return 
dw/this.widthDivCounter;
}


TileTale.prototype.moveend = function()
{    
    var 
zoom=this.map.getZoom();
    var 
b=this.map.getBounds();
    if(!
b)return false;
    
    
this.thisBounds={x1:b.x1,x2:b.x2,y1:b.y1,y2:b.y2,zoom:zoom};
    
    var 
w=(b.x2-b.x1)*0.2;
    var 
h=(b.y2-b.y1)*0.2;
    
this.performRequire(this.getTiles(b.x1-w,b.y1-h,b.x2+w,b.y2+h,zoom));
    return 
true;
}

TileTale.prototype.onRequestingChange = function (current_cnt)
{
  
}

TileTale.prototype.getBounds = function ()
{
    return 
this.thisBounds;
}


window.TileTale_jQuery = function (map)
{
}

TileTale_jQuery.prototype=new TileTale();

function 
SlicedAjax(params,generation){
    
this.params=params;
    
this.generation=generation-1;
    
this.ajax=0;
    
this.start();
}

SlicedAjax.prototype.start = function(){
    var 
_this=this;
    
this.timeout=setTimeout(function(){
        
_this.ajax=$.ajax(_this.params);
        
_this.timeout=0;
    },
Math.ceil(this.generation/2)*300);
   
// console.log("start"+this.generation);
}

SlicedAjax.prototype.abort = function(){
    if(
this.timeout)clearTimeout(this.timeout);
    if(
this.ajax){ this.ajax.abort();delete this.ajax;this.ajax=0;}
}

TileTale_jQuery.prototype.AjaxRequest = function (addr,params,generation)
{
   var 
jparams={cache:false,url:addr,error:params.onFail,success:params.onComplete,dataType:'json',contentType"application/json"}
   var 
res=new SlicedAjax(jparams,generation);
   return {
transport:{abort:function(){res.abort()}}};
}




/** пример инициализации **/
if(0)
{
 

ZTile=new TileTale_jQuery(map);
ZTile.init(map);

//7 - фото домов\дома
//9 - предложения продажи

ZTile.assignLayer(7,ZTile,
                  
                  
/*show*/function(meta,object,i){ object.shown=1;return object;},
                  
/*hide*/function(meta,object,i){ object.shown=0;return object;},
                  
/*apply*/function(meta,object,i){ return object;}
                                    
                  )

function 
tileend(){ZTile.moveend()};

this.map.addEventthis.map"moveend"tileend );

}





[CODE]/kMaps/ZTile.js

- А ты в армии служил?
- Конечно служил.
- Стрелял?
- Стрелял.
- Из пушки?
- Нет. Из автомата.
- А тебя убивали?
- Видишь, живой сижу.
- Ну, тогда спокойной ночи, Кащей Бессмертный
интернет