从坐标转换为像素 [英] Convert from coordinates to pixels

查看:128
本文介绍了从坐标转换为像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Google v3地图上实现右键单击上下文菜单,我需要获取像素x和y才能正确放置菜单.我得到了纬度和经度,有人能找到一个很好的解决方案来获取像素x和y吗?

I am implementing a rightclick context menu on my google v3 map and I need to get the pixel x and y to correctly position the menu. I get the lat and the lng, anyone have a nice solution to get the pixel x and y?

最好的问候

Henkemota

Henkemota

推荐答案

与以上答案的正确性:

index=x+(y*width) 

//(不是y * height ...,因为您要获取一条完整的水平像素线(例如1280px),然后将其乘以x所在的屏幕下方的行数(y),然后加上x在下一个完整行中占x像素.)

//(not y*height ... because you're taking one full horizontal line of pixels (e.g. 1280px) and multiplying that by the number of lines (y) down the screen at which x is, then adding x to account for x pixels over in the next full line.)

x = index % width
y = index / height

这篇关于从坐标转换为像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆