[ka-Map-users] Re: Speeding up tile display/download

bryn at brynr.ath.cx bryn at brynr.ath.cx
Thu Mar 8 19:43:19 EST 2007


Hi Steve,

I successfully got this hack working.
tileURL is set in init.php (line 313) and yours will look something like
the following:

$szResult.="this.tileURL=new Array('http://dns1/tile.php',
'http://dns2/tile.php', 'http://dns3/tile.php', 'http://dns4/tile.php');";

I found I also had to create a new variable in kaMap.js in order for this
to work.
under line 184 (this.tileURL=null;) I added:
this.tileIDX=0;

just for reference, the end of my setTile() function [lines 2267-2298]
looks like:

	var idx=this._map.kaMap.tileIDX;
	if (this._map.kaMap.tileURL[idx].indexOf('?') != -1)
	{
		if (this._map.kaMap.tileURL[idx].slice(-1) != '&')
		{
			q = '&';
		}
		else
		{
			q = '';
		}
	}
	else
	{
		var src = this._map.kaMap.tileURL[idx] +
		q + 'map=' + this._map.name +
		'&t=' + t +
		'&l=' + l +
		szScale + szForce + szGroup + szImageformat + szTimestamp + szVersion;
	}
	if (img.src != src)
	{
		img.style.visibility = 'hidden';
		img.src = src;
	}
	idx++;
	if(idx==this._map.kaMap.tileURL.length)
		this._map.kaMap.tileIDX=0;
	else
		this._map.kaMap.tileIDX=idx;
	}
};

I hope this helped, good luck
Bryn


>Hi,
>
>Thank you Ionut for the great tip!
>
>Can anybody help by filling in some details?
>
>Specifically, I am not sure where tileURL should be set and what its
>contents should look like.
>
>Also, is it correct that the modifications be made to kaMap.js ?  Do other
>files need modification as well?
>
>Thanks,
>
>-Steve
>
>
>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Sat, 17 Feb 2007 21:00:46 +0200
>> From: Ionut Muntean <ionut at muntean.ro>
>> Subject: [ka-Map-users] Speeding up tile display/download
>> To: ka-map-users at lists.maptools.org
>> Message-ID: <45D750DE.9030709 at muntean.ro>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> Hi,
>>
>> Don't know if this is already known by you, but it is worth a try to
>> share this.
>>
>> I've always wondered why google maps displays the tiles so fast.
>> mt0..mt3.google.com resolves to the same server. So what's the clue?
>> Fortunately, i've bumped on some web page where it says that IE and
>> Firefox have only 4 sockets for downloading the web page content.
>>
>> So, what if altering kaMap.setTile() to use, sequentially, 4 server
>> names to build img.src?
>>
>> The improvement was dramatically! The tiles are now loading 4 to 5 times
>> faster.
>>
>> tileURL is now an array that holds 4 server names that are basically
>> only cnames in the dns server to the same server.
>>
>> The setTile() function was modified to sequential build the img.src like
>> this (this is only the last part of the function):
>>
>> .....
>>     var idx = this._map.kaMap.tileIDX;
>>      if (this._map.kaMap.tileURL[idx].indexOf('?') != -1) {
>>          if (this._map.kaMap.tileURL[idx].slice(-1) != '&') {
>>              q = '&';
>>          } else {
>>              q = '';
>>          }
>>      } else {
>>          var src = this._map.kaMap.tileURL[idx] +
>>          q + 'map=' + this._map.name +
>>          '&t=' + t +
>>          '&l=' + l +
>>          szScale + szForce + szGroup + szImageformat + szTimestamp +
>> szVersion;
>>      }
>>      if (img.src != src) {
>>          img.style.visibility = 'hidden';
>>          img.src = src;
>>      }
>>     idx++;
>>     if (idx == this._map.kaMap.tileURL.length) {
>>       this._map.kaMap.tileIDX = 0;
>>     } else {
>>       this._map.kaMap.tileIDX = idx;
>>     }
>> }
>>
>>
>> Of course this method presumes that you have access to the DNS servers
>> of the company or whoever is hosting your pages.
>>
>> Hope this is usefull info for someone.
>>
>> / IM
>>
>>
>> ------------------------------
>
>--
>Steve Walker
>Middle Fork Geographic Information Services
>walker at mfgis.com
>360-671-2505



More information about the ka-Map-users mailing list