fromLatLngToPixel

本文介绍了如何在不使用GProjection().fromLatLngToPixel的情况下计算谷歌地图瓦片的坐标。主要内容包括将经纬度转换为像素位置,计算x和y坐标,并构造地图瓦片的URL。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

It's not simple at all if you're not allowed to make calls to
        GProjection().fromLatLngToPixel(point,zoom)

The rest of the formula is straight forward:

        Convert your lat lon to a pixel position.

        Divide each component by 256 (the tilesize)

        Discard any fractions to give integer values for x and y

        Pick a tile version number, like "ap.31"

        Build the URL like

        http://mt0.google.com/mt?n=404&v=" + version + &x=" + x
                + "&y=" +y+ "&zoom=" + (17-zoom)

I can show you the code for GProjection().fromLatLngToPixel(point,zoom),
but it relies on some other stuff that's already been pre-calculated
when the GProjection was created. It looks like this:

var c=this,d=c.Te[b],e=D(d.x+a.lng()*c.Ve[b]),f=Qa(Math.sin(xd(a.lat()))
,-0.9999,0.9999),g=D(d.y+0.5*Math.log((1+f)/(1-f))*-c.We[b]);

With "e" and "g" being the values that you want.

I think c.Te[b] is equivalent to GPoint(256*2^(b+1),256*2^(b+1)) and
c.Ve[b] is 256*2^(b+1)/360, but I could easily be out by a factor of 2
either way.
--
The Blackpool Community Church Javascript Team
http://www.econym.demon.co.uk/googlemaps/

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值