google卫星地图的url计算

By admin at 2007-11-16 • 0人收藏 • 1625人看过
通过url跟踪,可以方便地取得google maps普通地图的图片url,如:
GET /mt?n=404&v=w2.10&x=3&y=6&zoom=13 HTTP/1.1
而对卫星地图图片的url像:
GET /kh?n=404&v=5&t=tqtsq HTTP/1.1
就不知它的t参数含义了。
今天看了看地图的.js文件,找到了如下代码,可以计算这个参数,也就可以动态构造出相应的url去批量下载卫星地图了。
代码如下:

<script>

function MapObj()
{
this.x;
this.y;
}

function test()
{
var o = new MapObj();
var ss = document.all("txtPos").value.split(",");
o.x = ss[0];
o.y = ss[1];
var zoom = parseInt(document.all("txtFactor").value);
var ret = cal(o, 17 - zoom);
document.all("txtMess").value = ret;
}
function cal(a,b)
{
var c=Math.pow(2,b);//比例参数, 地图宽度图片数量
var d=a.x;//a is the map object
var e=a.y;
var f="t";
/*
zoom = 13; b = 4; c = 2^4 = 16;
*/
for(var g=0;g<b;g++)//
{
c=c/2; // c / 2
if(e<c) //a.y < c
{
if(d<c)//a.x < c
{
f+="q"
}
else//a.x >= c
{
f+="r";
d-=c //a.x = a.x - c
}
}
else//a.y >= c
{
if(d<c)//a.x < c
{
f+="t";
e-=c //a.y = a.y - c
}
else//a.x >= c
{
f+="s";
d-=c; //a.x = a.x - c
e-=c //a.y = a.y - c
}
}
}
return "t=" + f;
//var h=(a.x+a.y)%this.wa.length;//
//return this.wa[h]+"t="+f
}
</script>
(x,y)<input type=text id="txtPos" value="3,7"><br>
zoom:<input type=text id="txtFactor" value="13">
<input type=button value="check" onclick="test()">

<br>
   <input type=text id="txtMess">

1 个回复 | 最后更新于 2008-07-30
2008-07-30   #1


 
提示:你可先修改部分代码,再按运行   

登录后方可回帖

登 录
信息栏

Carbon Forum是一个基于话题的高性能轻型PHP论坛

下载地址:Carbon Forum v5.9.0
QQ群:12607708(QQ我不常上)

donate

手机支付宝扫描上方二维码可向本项目捐款

粤公网安备 44030602003677号
粤ICP备17135490号

Loading...